코딩테스트/[C#] 프로그래머스

[프로그래머스 | Lv.0] 배열 자르기

냠냠쿠 2023. 8. 13. 19:26
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/120833?language=csharp

📝 나의 풀이

using System;
using System.Collections.Generic;

public class Solution {
    public int[] solution(int[] numbers, int num1, int num2) {
        List<int> list = new List<int>();
        
        
        for(int i = num1; i <= num2; i++)
        {
            list.Add(numbers[i]);
        }        
        int[] answer = list.ToArray();
        
        return answer;
    }
}
728x90