Monotone Function, O(N log N)
When the array itself isn't what we search, but the answer is. If a candidate value works, every larger (or every smaller) value also works - that monotonicity lets us binary-search the answer space and replace a scan with a feasibility(mid) check. Each check costs O(N), and we run log(range) of them.
Split Input Array
Guess a capacity / size / threshold, then greedily verify it can partition the array within the allowed number of pieces.
1011. Capacity To Ship Packages Within D Days
410. Split Array Largest Sum
875. Koko Eating Bananas
1482. Minimum Number of Days to Make m Bouquets
1231. Divide Chocolate
More problems built on the same "guess the answer, verify greedily" shape:
- 774. Minimize Max Distance to Gas Station (Hard)
- 1891. Cutting Ribbons (Medium)
- 2226. Maximum Candies Allocated to K Children (Medium)
- 2064. Minimized Maximum of Products Distributed to Any Store (Medium)
- 2137. Pour Water Between Buckets to Make Water Levels Equal (Medium)
- 2387. Median of a Row Wise Sorted Matrix (Medium)
Kth Smallest
Binary-search the value, and let the feasibility check count how many elements fall at or below mid.