Created
January 4, 2013 21:27
next permutation II
This file contains hidden or 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
#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