Find Right Interval — Binary Search on Sorted Start Points
For each interval, find the one with the smallest start point greater than or equal to its end — a clean binary search problem that teaches index-preserving sort patterns.
1582 articles
For each interval, find the one with the smallest start point greater than or equal to its end — a clean binary search problem that teaches index-preserving sort patterns.
Sort an array by element frequency ascending (ties broken by value descending) using a frequency map and custom comparator — a clean problem that tests mastery of custom sort keys.
Find the kth largest level sum in a binary tree by computing all level sums with BFS and selecting the kth largest using a min-heap — a clean combination of BFS and heap selection.
Minimize the total cost to hire k workers by always choosing the cheapest candidate from the first or last p candidates using two min-heaps expanding inward from both ends.
Design a seat manager that always reserves the lowest available seat number and supports unreservation using a min-heap — the canonical example of heap-based resource management.