class Solution {
public int[] solution(int[] arr) {
int[] answer = {};
return answer;
}
}
class Solution {
public int[] solution(int[] arr) {
int len = arr.length;
int tmp = 1;
while (tmp < len) {
tmp *= 2;
}
int[] answer = new int[tmp];
for (int i = 0; i < arr.length; i++) {
answer[i] = arr[i];
}
return answer;
}
}
import java.util.Arrays;
class Solution {
public int[] solution(int[] arr) {
return Arrays.copyOf(arr, (int) Math.pow(2, Math.ceil(Math.log(arr.length) / Math.log(2))));
}
}
Arrays.copyOf()
Math 클래스를 이용하는 방법