Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]
public class Solution { public List
> permute(int[] nums) { if(nums==null || nums.length==0){ return null;} List
> resList=new ArrayList
>(); List item=new ArrayList (); boolean[] isVisited=new boolean[nums.length]; backTracking(nums, item, resList, isVisited); return resList; } public void backTracking(int[] nums, List item, List
> resList, boolean[] isVisited){ if(item.size()==nums.length){ resList.add(new ArrayList (item)); return; } for(int i=0; i