코딩테스트
코딩테스트 연습 > 2017 팁스타운 > 예상 대진표
안양사람
2020. 8. 27. 20:54
728x90
SMALL
내풀이
function solution(n,a,b){
let num=0;
while(true){
a=Math.ceil(a/2);
b=Math.ceil(b/2);
num++;
if(a===b){
return num;
}
}
}
다른사람풀이
function solution(n,a,b){
let num=0;
while(a!==b){
a=Math.ceil(a/2);
b=Math.ceil(b/2);
num++;
}
return num;
}
그냥 바로 풀렸다 내풀이나 다른사람풀이나 복잡도면에서는 차이가 없다.
근데 밑에풀이가 조금더 깔끔?해보이는
728x90
LIST