Programmer:)
[ 프로그래머스 / C# ] K번째 수 본문
반응형
문제
https://programmers.co.kr/learn/courses/30/lessons/42748
내가 제출한 코드
using System;
using System.Collections.Generic;
public class Solution {
public int[] solution(int[] array, int[,] commands)
{
List<int> temp = new List<int>();
List<int> answer = new List<int>();
for (int i = 0; i < commands.GetLongLength(0); i++)
{
int min = commands[i, 0];
int max = commands[i, 1];
int index = commands[i,2];
for (int j = min-1; j < max; j++)
{
temp.Add(array[j]);
}
temp.Sort();
answer.Add(temp[index-1]);
temp.Clear();
}
return answer.ToArray();
}
}
반응형
'프로그래머스 정복 > C#' 카테고리의 다른 글
[ 프로그래머스 / C# ] 숫자 카드 나누기 (0) | 2022.11.18 |
---|---|
[ 프로그래머스 / C# ] 과일 장수 (0) | 2022.11.16 |
[ 프로그래머스 / C# ] 음양 더하기 (0) | 2021.10.25 |
[ 프로그래머스 / C# ] 없는숫자 더하기(Except) (0) | 2021.10.22 |
[ 프로그래머스 / C# ] 숫자 문자열과 영단어(2021 카카오 채용 연계 인턴쉽)(Dictionary) (0) | 2021.10.22 |
Comments