반응형

class Solution {
public int[] solution(int[] numbers) {
int[] answer = new int[numbers.length];
for(int i=0; i<numbers.length; i++){
answer[i] = 2*numbers[i];
}
return answer;
}
}
다른 풀이
import java.util.*;
class Solution {
public ArrayList solution(int[] numbers) {
ArrayList<Integer> answer = new ArrayList<>();
for(int num : numbers){
answer.add(num*2);
}
return answer;
}
}
반응형
'코딩테스트' 카테고리의 다른 글
| [프로그래머스/Java] 공배수 (0) | 2025.07.17 |
|---|---|
| [프로그래머스/Java] n의 배수 (0) | 2025.07.17 |
| [프로그래머스/JAVA] 두 수의 연산값 비교하기 (0) | 2025.07.16 |
| [프로그래머스/JAVA] 더 크게 합치기 (Integer.toString(), Integer.parseInt(), Math.max(a,b)) (0) | 2025.07.16 |
| [프로그래머스/JAVA] 문자열 곱하기 (0) | 2025.07.16 |