작성일 : January 9, 2022
문제 : https://programmers.co.kr/learn/courses/30/lessons/12911
해설 : https://haesoo9410.tistory.com/305
function solution(n) {
var answer = n+1;
while(n) {
const checkOneCount = num => num.toString(2).split('').filter(char => char === '1').length;
const isSameOneCount = (a,b) => checkOneCount(a) === checkOneCount(b);
if(n < answer && isSameOneCount(n, answer)) {
break;
} else {
answer++;
}
}
return answer;
}
function solution(n) {
const oneNum = n.toString(2).split("1").length;
while (true) {
n++;
if (n.toString(2).split("1").length === oneNum) return n;
}
}