반응형
문제 : 정수 배열 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;
}
}
반응형
'알골 이모저모' 카테고리의 다른 글
프로그래머스 - 아이스 아메리카노 (0) | 2023.10.05 |
---|---|
프로그래머스 - 짝수 홀수 개수 (0) | 2023.10.05 |
프로그래머스 - 편지 (0) | 2023.10.05 |
프로그래머스 - 최댓값 만들기 (1) (0) | 2023.10.05 |
프로그래머스 - 점의 위치 구하기 (0) | 2023.10.04 |