https://leetcode-cn.com/problems/permutations/description/
class Solution {
public List<List<Integer>> permute(int[] nums)
{
List<List<Integer>> res=new ArrayList<List<Integer>>();
per(nums,0,nums.length-1,res);
return res;
}
public void per(int[] nums,int start,int end,List<List<Integer>> res)
{
if(start==end)
{
List<Integer> a=new ArrayList<Integer>();
for(int i=0;i<nums.length;i++)
{
a.add(nums[i]);
}
res.add(a);
return;
}
for(int i=start;i<=end;i++)
{
int temp=nums[i];
nums[i]=nums[start];
nums[start]=temp;
per(nums,start+1,end,res);
temp=nums[i];
nums[i]=nums[start];
nums[start]=temp;
}
}
}