挺经典的回溯题的。
class Solution {
public:vector<vector<int>> result;void recursion(vector<int>& nums,vector<int>& now){if(nums.size()==0){result.push_back(now);return ;}for(int i=0;i<nums.size();i++){now.push_back(nums[i]);nums.erase(nums.begin()+i);recursion(nums,now);nums.insert(nums.begin()+i,now[now.size()-1]);now.pop_back();}}vector<vector<int>> permute(vector<int>& nums) {vector<int> r;recursion(nums,r);return result;}
};