class Solution {
public:
void nextPermutation(vector<int>& nums) {
if(next_permutation(nums.begin(),nums.end()))
;
else
sort(nums.begin(),nums.end());
}
};
@jiangshanglong std::next_permutation()
already creates the first permutation if returning false. So you don't need the call to sort()
.