| 1 | class Solution { |
| 2 | public: |
| 3 | vector<vector<int>> ans; |
| 4 | void helper(vector <int>& nums, int i){ |
| 5 | if (i==nums.size()){ // Base Case |
| 6 | ans.push_back(nums); |
| 7 | return; |
| 8 | } |
| 9 | for (int j=i;j<nums.size();j++){ |
| 10 | swap(nums[i],nums[j]); |
| 11 | helper(nums,i+1); |
| 12 | // backtrack |
| 13 | swap(nums[i],nums[j]); |
| 14 | } |
| 15 | return; |
| 16 | |
| 17 | } |
| 18 | vector<vector<int>> permute(vector<int>& nums) { |
| 19 | helper(nums,0); |
| 20 | return ans; |
| 21 | } |
| 22 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected