Skip to content

Commit 2ef3870

Browse files
author
mukul
committed
Lexographically smallest after a swap
1 parent abcc85f commit 2ef3870

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: LeetcodeProblems/Algorithms/easy/Lexographic_smallest_after_swap.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ how to check the parity of the number:
5959
* @return {string}
6060
*/
6161
var getSmallestString = function(s) {
62-
let arr = s.split('').map(Number);
62+
let arr = s.split("").map(Number);
6363

6464
const getParity = (num) => {
65-
if(num&1 === 0) return 'even';
66-
else return 'odd';
67-
}
65+
if(num&1 === 0) return "even";
66+
else return "odd";
67+
};
6868

6969
for(let i = 0; i< s.length - 1; i++) {
7070
if(arr[i] > arr[i+1] && getParity(arr[i]) === getParity(arr[i + 1])) {
@@ -75,7 +75,7 @@ var getSmallestString = function(s) {
7575
}
7676
}
7777

78-
return arr.join('');
78+
return arr.join("");
7979
};
8080

8181
module.exports.getSmallestString = getSmallestString;

0 commit comments

Comments
 (0)