
using System;
class Solution
{
public int solution(int n)
{
int curCount = CountOnes(n);
int nextCount = n + 1;
while(true)
{
if(CountOnes(nextCount) == curCount)
return nextCount;
nextCount++;
}
}
public int CountOnes(int n)
{
return Convert.ToString(n,2).Split('1').Length - 1;
}
}
생각보다 쉬운 문제였습니다..