본문 바로가기
기타/프로그래머스

[프로그래머스] Lv.0 배열 두 배 만들기 - 자바(java)

by qkzkdo 2023. 8. 10.
728x90

문제 설명
정수 배열 numbers가 매개변수로 주어집니다. numbers의 각 원소에 두배한 원소를 가진 배열을 return하도록 solution 함수를 완성해주세요.

 

 

내가 작성한 답

class Solution {
    public int[] solution(int[] numbers) {
        int[] answer = new int[numbers.length];

        for(int i=0; i<numbers.length; i++){
            answer[i] = numbers[i] * 2;
        }

        return answer;
    }
}

 

728x90