답안 :
class Solution {
public int solution(int n, int a, int b) {
int answer = 1;
while (true) {
a = (a + 1) / 2;
b = (b + 1) / 2;
if (a == b)
break;
answer++;
}
return answer;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Solution s = new Solution();
int n = 8;
int a = 4;
int b = 7;
System.out.println(s.solution(n, a, b));
}
}
- action 값에 따른 확인률에 대한 평균 구하기.
답안 :
select s.user_id, round(avg(if(c.action="confirmed",1,0)),2) as confirmation_rate
from Signups as s
left join Confirmations as c
on s.user_id= c.user_id
group by user_id;