알골 이모저모
프로그래머스 - 배열 두 배 만들기
진진이랑
2023. 10. 5. 07:32
728x90
반응형
문제 : 정수 배열 numbers가 매개변수로 주어집니다. numbers의 각 원소에 두배한 원소를 가진 배열을 return하도록 solution 함수를 완성해주세요.
풀이 :
class Solution {
public int[] solution(int[] numbers) {
int len = numbers.length;
int[] answer = new int[len];
for(int i=0; i<len; i++){
answer[i] = numbers[i]*2;
}
return answer;
}
}
728x90
반응형