Untitled
plain_text
a month ago
378 B
1
Indexable
Never
int announce(int mDuration, int M) { TreeSet<Employee> set = new TreeSet<>((a, b) -> a.end - b.end); for (Employee e : set) { set.add(e); int announceEnd = e.start + mDuration - 1; while (!set.isEmpty() && set.first().end < announceEnd) set.pollFirst(); if (set.size() == M) return e.start; } return -1; }