class Solution {
public int eraseOverlapIntervals(int[][] intervals) {
//same as N meetings/no. of activities
//sort the intervals based on end time of each pair
Queue<Pair<Integer,Integer>> q = new PriorityQueue<>((a,b)->a.getValue()-b.getValue());
for(int i = 0;i<intervals.length;i++){
q.add(new Pair(intervals[i][0], intervals[i][1]));
}
int previousEndTime = Integer.MIN_VALUE;
int count = 0;
while(!q.isEmpty()){
Pair<Integer,Integer> p = q.remove();
int start = p.getKey();
int end = p.getValue();
if(start>=previousEndTime){
count++;
previousEndTime = end;
}
}
return intervals.length-count;
}
}
Ähnliche Beiträge
Auch interessante Nachrichten Non overlapping intervals
Thematisch verwandte Begriffe: overlapping, intervals · 6 Treffer
Using LLMs and ESRE to find similar user sessions
Catching Cross-Language Copy-Paste Debt with Static Analysis and AI Pair-Programmers
🚨 Typosquatting packages on PyPI are targeting 𝗿𝗲𝗾𝘂𝗲𝘀𝘁𝘀, one of the most widely used Python packages. Catch them before compromise.
7 Async Patterns for Running Agents Concurrently in Python
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
SOCIAL SHARE CARD GENERATOR