| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 시바견
- DWG
- Generator
- Python Code
- 315. Count of Smaller Numbers After Self
- Substring with Concatenation of All Words
- 43. Multiply Strings
- Decorator
- Python
- iterator
- 밴픽
- LeetCode
- Regular Expression
- 715. Range Module
- kaggle
- 운영체제
- shiba
- Python Implementation
- 파이썬
- concurrency
- Convert Sorted List to Binary Search Tree
- t1
- 30. Substring with Concatenation of All Words
- 프로그래머스
- Class
- data science
- attribute
- 109. Convert Sorted List to Binary Search Tree
- Protocol
- 컴퓨터의 구조
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 |