728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181923
소스코드
public int[] solution(int[] arr, int[,] queries)
{
int[] answer = new int[queries.GetLength(0)];
for (int i = 0; i < queries.GetLength(0); i++)
{
int s = queries[i, 0];
int e = queries[i, 1];
int k = queries[i, 2];
int result = -1;
for (int j = s; j <= e; j++)
{
if (arr[j] > k && result == -1)
result = arr[j];
if (result > arr[j])
result = arr[j];
}
answer[i] = result;
}
return answer;
}
728x90
'코딩공부 > 프로그래머스' 카테고리의 다른 글
[프로그래머스]Lv.0 카운트 업 C# (0) | 2023.06.02 |
---|---|
[프로그래머스]Lv.0 배열 만들기 2 C# (0) | 2023.06.02 |
[프로그래머스]Lv.0 수열과 구간 쿼리 3 C# (0) | 2023.06.02 |
[프로그래머스]Lv.0 수 조작하기 2 C# (0) | 2023.06.02 |
[프로그래머스]Lv.0 수 조작하기1 C# (0) | 2023.06.02 |