Untitled
Darin
plain_text
2 years ago
378 B
10
Indexable
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;
}
Editor is loading...