문제 링크 : Maximum Odd Binary Number
/**
* @param {string} s
* @return {string}
*/
var maximumOddBinaryNumber = function(s) {
let oneCnt = 0
let zeroCnt = 0
for(let el of s) {
if(el === '1') {
oneCnt++
}else {
zeroCnt++
}
}
return oneCnt > 1 ? '1'.repeat(oneCnt-1)+'0'.repeat(zeroCnt)+'1' : '0'.repeat(zeroCnt)+'1'
};
/**
* @param {string} s
* @return {string}
*/
var maximumOddBinaryNumber = function(s) {
s = [...s].sort((a,b) => b-a)
s.push(s.shift())
return s.join('')
};