Binary Search
Binary search halves a sorted range at every step until one value is left. The harder part is noticing when a problem hides a sorted order you can search over, like the slowest eating speed in Koko Eating Bananas or the largest minimum gap in Magnetic Force Between Two Balls.
The four chapters go from searching a sorted array, to binary search on the answer, to ternary search on functions with a single peak, and end with mixed problems. Take it after the sliding window plan, or on its own if binary search on the answer still feels like guesswork.
Want company while you work through this list? Sign in, open the study room, and your heroine will bring you the problems one at a time.
I. Binary Search
§1.1 Fundamentals
§1.2 Advanced
II. Binary Search on Answer
§2.1 Minimize Answer
§2.2 Maximize Answer
§2.3 Binary Search on an Indirect Value
| Problem | Rating |
|---|---|
| 3143. Maximum Points Inside the Square | 1697 |
| 1648. Sell Diminishing Valued Colored Balls | 2050 |
§2.4 Minimize the Maximum
§2.5 Maximize the Minimum
§2.6 K-th Smallest / Largest
III. Ternary Search
Ternary Search
| Problem | Rating |
|---|---|
| 1515. Best Position for a Service Centre | 2157 |
IV. Miscellaneous
Miscellaneous
| Problem | Rating |
|---|---|
| 69. Sqrtx | Unrated |
| 74. Search a 2D Matrix | Unrated |
| 278. First Bad Version | Unrated |
| 374. Guess Number Higher OR Lower | Unrated |
| 162. Find Peak Element | Unrated |
| 1901. Find a Peak Element II | Unrated |
| 852. Peak Index in a Mountain Array | Unrated |
| 1095. Find in Mountain Array | 1827 |
| 153. Find Minimum in Rotated Sorted Array | Unrated |
| 154. Find Minimum in Rotated Sorted Array II | Unrated |
| 33. Search in Rotated Sorted Array | Unrated |
| 81. Search in Rotated Sorted Array II | Unrated |
| 222. Count Complete Tree Nodes | Unrated |
| 1539. Kth Missing Positive Number | Unrated |
| 540. Single Element in a Sorted Array | Unrated |
| 4. Median of Two Sorted Arrays | Unrated |
The route suggests this plan after Sliding Window & Two Pointers, but the order is not a lock, and your heroine still brings the next unsolved problem one at a time.
Ratings come from zerotrac's LeetCode contest ratings. Some problems have no zerotrac rating and are marked Unrated.
Open the study room