programmers_단속카메라_java
2023. 3. 1. 14:20ㆍAlgorithm/Programmers
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/42884
import java.util.*;
class Solution {
public int solution(int[][] routes) {
int answer = 0;
Arrays.sort(routes, (o1, o2) -> o1[1] - o2[1]);
int pos = Integer.MIN_VALUE;
for(int[] route : routes) {
if(pos < route[0]) {
pos = route[1];
answer++;
}
}
return answer;
}
}
'Algorithm > Programmers' 카테고리의 다른 글
programmers_기지국 설치_java (0) | 2023.03.04 |
---|---|
programmers_숫자 게임_java (0) | 2023.03.01 |
programmers_등굣길_java (0) | 2023.02.28 |
programmers_야근 지수_java (0) | 2023.02.28 |
programmers_최고의 집합_java (0) | 2023.02.28 |