๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/12985?language=java
ํ์ด
class Solution
{
public int solution(int n, int a, int b)
{
int answer = 0;
while(true){
a = a / 2 + a % 2;
b = b / 2 + b % 2;
answer++;
if(a==b) break;
}
return answer;
}
}
'๐๏ธ Algorithm > โฌ ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
โฌ [Programmers] [Java] [Level2] ์ ํ์ ์๊ฐ์ด๋ (0) | 2024.01.16 |
---|---|
โฌ [Programmers] [Java] [Level2] ์์ด ๋๋ง์๊ธฐ (0) | 2024.01.11 |
โฌ [Programmers] [Java] [Level2] ์ง์ง์ด ์ ๊ฑฐํ๊ธฐ (0) | 2024.01.07 |
โฌ [Programmers] [Java] [Level2] ์ด์ง ๋ณํ ๋ฐ๋ณตํ๊ธฐ (1) | 2024.01.04 |
โฌ [Programmers] [Java] [Level2] ์ต์๊ฐ ๋ง๋ค๊ธฐ (2) | 2024.01.03 |