Am I Cheating using next_permutation?


  • 0
    H
    class Solution {
    public:
        vector<vector<int>> permuteUnique(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;
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.