@@ -0,0 +1,982 @@
+import java.util.List;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0A%0Aclass Solution %7B%0A    public List%3CList%3CInteger%3E%3E permuteUnique(int%5B%5D nums) %7B%0A        List%3CList%3CInteger%3E%3E res = new ArrayList%3C%3E();%0A        boolean%5B%5D used = new boolean%5Bnums.length%5D;%0A        Arrays.fill(used, false);%0A%0A        generatePerms(nums, 0, new ArrayList%3CInteger%3E(), used, res);%0A%0A        return res;%0A    %7D%0A%0A    private void generatePerms(int%5B%5D nums, int idx, List%3CInteger%3E p, boolean%5B%5D used, List%3CList%3CInteger%3E%3E res) %7B%0A        if (idx == nums.length) %7B%0A            res.add(new ArrayList%3C%3E(p));%0A            return;%0A        %7D%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            if (used%5Bi%5D) %7B continue; %7D%0A            if (i %3E 0 && nums%5Bi - 1%5D == nums%5Bi%5D && !used%5Bi - 1%5D) %7B continue; %7D%0A            p.add(nums%5Bi%5D);%0A            used%5Bi%5D = true;%0A            generatePerms(nums, idx + 1, p, used, res);%0A            p.remove(p.size() - 1);%0A            used%5Bi%5D = false;%0A        %7D%0A        return;%0A    %7D%0A%7D

47. Permutations II