Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bf013e5

Browse files
committed
Add solution #31
1 parent ea056c6 commit bf013e5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

0031-next-permutation.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* https://leetcode.com/problems/next-permutation/
44
* Difficulty: Medium
55
*
6-
* Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
6+
* Implement next permutation, which rearranges numbers into the
7+
* lexicographically next greater permutation of numbers.
78
*
8-
* If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
9+
* If such an arrangement is not possible, it must rearrange it
10+
* as the lowest possible order (i.e., sorted in ascending order).
911
*
1012
* The replacement must be in place and use only constant extra memory.
1113
*/
@@ -14,7 +16,7 @@
1416
* @param {number[]} nums
1517
* @return {void} Do not return anything, modify nums in-place instead.
1618
*/
17-
var nextPermutation = function(nums) {
19+
var nextPermutation = function(nums) {
1820
let i = nums.length - 2;
1921

2022
while (i >= 0 && nums[i + 1] <= nums[i]) {
@@ -47,4 +49,4 @@ function swap(nums, i, j) {
4749
const temp = nums[i];
4850
nums[i] = nums[j];
4951
nums[j] = temp;
50-
}
52+
}

0 commit comments

Comments
 (0)