코딩 테스트/Lv.0

마지막 두 원소

gaon99 2025. 1. 13. 20:10

using System;

public class Solution {
    public int[] solution(int[] num_list) {
        int end = num_list.Length;
        int[] answer = new int[end+1];
        
        Array.Copy(num_list, answer, end);
        answer[end] = (num_list[end-1]>num_list[end-2]) ? num_list[end-1] - num_list[end-2] : num_list[end-1] * 2;
     
        return answer;
    }
}

'코딩 테스트 > Lv.0' 카테고리의 다른 글

수 조작하기 2  (0) 2025.01.15
수 조작하기 1  (0) 2025.01.15
이어 붙인 수  (0) 2025.01.13
원소들의 곱과 합  (0) 2025.01.13
주사위 게임 2  (0) 2025.01.13