标签:ons nbsp span array turn public [] back new
backtrack
1 class Solution { 2 List<List<Integer>> res = new ArrayList<>(); 3 public List<List<Integer>> permute(int[] nums) { 4 backtrack(nums, new ArrayList<>()); 5 return res; 6 } 7 8 public void backtrack(int[] nums, List<Integer> list) { 9 if(list.size() == nums.length) { 10 res.add(new ArrayList<>(list)); 11 } 12 for(int i = 0; i < nums.length; i++) { 13 if(list.contains(nums[i])) continue; 14 list.add(nums[i]); 15 backtrack(nums, list); 16 list.remove(list.size() - 1); 17 } 18 } 19 }
标签:ons nbsp span array turn public [] back new
原文地址:https://www.cnblogs.com/goPanama/p/9625379.html