class Solution {
public:
void nextPermutation(vector<int>& nums) {
int n = nums.size();
for (int i = nums.size() - 1; i >= 0; i --) {
for (int j = nums.size() - 1; j > i; j --) {
if(nums[j] > nums[i]) {
swap(nums[i], nums[j]);
reverse(nums.begin() + i + 1, nums.end());
return ;
}
}
}
reverse(nums.begin(), nums.end());
}
};