Skip to content

Instantly share code, notes, and snippets.

@ws6
Created January 4, 2013 21:27
Show Gist options
  • Save ws6/4456220 to your computer and use it in GitHub Desktop.
Save ws6/4456220 to your computer and use it in GitHub Desktop.
next permutation II
#include <algorithm>
#include <vector>
using namespace std ;
int int_cmp(int i, int j){ return (i<j) ;}
class Solution {
public:
vector<vector<int> > permuteUnique(vector<int> &num) {
sort(num.begin(), num.end(), int_cmp ) ;
vector<vector<int> > ret;
do{
ret.push_back( num );
}while(next_permutation(num.begin(), num.end())!=false);
return ret;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment