```
void help(vector<vector<int>>& res, vector<int>& cur, int start) {
if (start == cur.size()) {
res.push_back(cur);
} else {
for (int i = start; i < cur.size(); i++) {
swap(cur[start], cur[i]);
help(res, cur, start + 1);
swap(cur[start], cur[i]);
}
}
}
vector<vector<int>> permute(vector<int>& nums) {
vector<vector<int>> res;
help(res, nums, 0);
return res;
}
```