class Solution {
public:
void nextPermutation(vector<int>& nums) {
int size = nums.size();
if(size == 1){
return;
}
int i = size - 2;
while(i >= 0 && nums[i] >= nums[i + 1]){
i--;
}
if(i >= 0){
int j = size - 1;
while(j >= 0 && nums[i] >= nums[j]){
j--;
}
swap(nums[i], nums[j]);
}
reverse(nums.begin() + i + 1, nums.end());
}
};
02-15
411
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-16
106
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-20
375
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-18