本题要采用 回溯法 来解决
class Solution { public List<List<Integer>> permute(int[] nums) { List<List<Integer>> list = new ArrayList<>(); backtrack(list,new ArrayList<>(),nums); return list; } private void backtrack(List<List<>> list, List<Integer> tempList, int[] nums){ if(tempList.size()==nums.length){ list.add(new ArrayList<>(tempList)); }else{ for(int i=;i<nums.length;i++){ if(tempList.contains(nums[i])) continue; tempList.add(nums[i]); backtrack(list,temmpList,nums); tempList.remove(tempList.size()-1); } } } }