문제

기본적으로 주어진 코드 :
class Solution {
public int solution(int n, int t) {
int answer = 0;
return answer;
}
}
정답
class Solution {
public int solution(int n, int t) {
int answer = n;
for (int i = 0; i < t; i++) {
answer *= 2;
}
return answer;
}
}
- t 의 값이 1 증가할 때마다 반환값을 2배로 늘려야 합니다.
- t 값이 1이라도 한번은 2배로 늘려야하기 때문에 반복문의 시작값은 0 입니다.
Share article