2
public List<List<Integer>> permuteUnique(int[] nums) {3
List<List<Integer>> ans = new ArrayList<>();5
boolean used[] = new boolean[nums.length];7
permutationsFinder(nums, ans, new ArrayList<>(), used);12
static void permutationsFinder(13
int[] nums, List<List<Integer>> ans, List<Integer> list, boolean used[]) {14
if (list.size() == nums.length) {15
ans.add(new ArrayList<>(list));19
for (int i = 0; i < nums.length; i++) {20
if (used[i]) continue;21
if (i > 0 && nums[i] == nums[i - 1] && !used[i - 1]) continue;24
permutationsFinder(nums, ans, list, used);25
list.remove(list.size() - 1);