728x90
SMALL

using System;

public 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;
    }
}

 

/////

 

파이썬

 

/////

def solution(numbers):
    return [num*2 for num in numbers]

 

자바

 

class Solution {
    public int[] solution(int[] numbers) {
        int[] answer = {};
        answer = new int[numbers.length];
        
        for(int i=0; i<answer.length; i++)
        {
            answer[i] = numbers[i]*2;
        }
        
        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;
    }
}
728x90

설정

트랙백

댓글