일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Substring with Concatenation of All Words
- LeetCode
- Protocol
- Generator
- Class
- DWG
- 715. Range Module
- Regular Expression
- iterator
- 30. Substring with Concatenation of All Words
- Python
- 43. Multiply Strings
- t1
- Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- 밴픽
- Decorator
- 시바견
- shiba
- kaggle
- Python Code
- data science
- 315. Count of Smaller Numbers After Self
- concurrency
- Python Implementation
- 109. Convert Sorted List to Binary Search Tree
- 운영체제
- attribute
- 프로그래머스
- 파이썬
Archives
- Today
- Total
Scribbling
[Java 101] 435. Non-overlapping Intervals - Comparator 본문
Computer Science/Java
[Java 101] 435. Non-overlapping Intervals - Comparator
focalpoint 2023. 3. 15. 05:14class Solution {
public int eraseOverlapIntervals(int[][] intervals) {
if (intervals.length == 0) return 0;
Arrays.sort(intervals, new Comparator<int []>(){
@Override
public int compare(int[] o1, int[] o2) {
return o1[1]-o2[1];
}
});
int cnt = 1;
int end = intervals[0][1];
for (int i=1; i<intervals.length; i++) {
if (intervals[i][0] >= end) {
cnt += 1;
end = intervals[i][1];
}
}
return intervals.length - cnt;
}
}
'Computer Science > Java' 카테고리의 다른 글
[Java] 1481. Least Number of Unique Integers after K Removals (0) | 2024.02.16 |
---|---|
[Java] LeetCode: 1606. Find Servers That Handled Most Number of Requests (0) | 2023.08.27 |
[Java 101] 211. Design Add and Search Words Data Structure - trie (0) | 2023.03.11 |
[Java101] Trie Implementation (0) | 2023.03.08 |
[Java 101] 102. Binary Tree Level Order Traversal - Queue (0) | 2023.03.04 |