Created
November 9, 2020 02:47
-
-
Save ABHIINAV12/e27c1274c01fd342e29e053ee58a1223 to your computer and use it in GitHub Desktop.
Given a collection of distinct integers, return all possible permutations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
vector<vector<int>> permute(vector<int>& nums) { | |
vector<vector<int>> ret; | |
sort(nums.begin(),nums.end()); | |
do{ | |
ret.push_back(nums); | |
}while(next_permutation(nums.begin(),nums.end())); | |
return ret; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment