有重复的数组,球排列的笛卡尔集

Given a collection of numbers that might contain duplicates, return all possible unique permutations.

class Solution {
    public List> permuteUnique(int[] nums) {
        List> res = new ArrayList<>();
        Arrays.sort(nums);
        permu(nums,res,new boolean[nums.length],new ArrayList(),0);
        return res;
    }
    public void permu(int[] nums,List> res,boolean[] visited,ArrayList cur,int index){
        if(index == nums.length){
            res.add(new ArrayList(cur));
            return;
        }
        for(int i = 0,len = nums.length;i

你可能感兴趣的:(有重复的数组,球排列的笛卡尔集)