Skip to content

Commit

Permalink
Time: 78 ms (46.59%) | Memory: 53 MB (32.00%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Mar 1, 2024
1 parent 2f892b2 commit eafc2c1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 3055-maximum-odd-binary-number/maximum-odd-binary-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @param {string} s
* @return {string}
*/
var maximumOddBinaryNumber = function(s) {
let chars = s.split('').sort().reverse();
for (let i = chars.length - 1; i >= 0; i--) {
if (chars[i] === '1') {
[chars[i], chars[chars.length - 1]] = [chars[chars.length - 1], chars[i]];
break;
}
}
return chars.join('');
};

0 comments on commit eafc2c1

Please sign in to comment.