Skip to content

Files

Latest commit

1e3f6c3 · May 19, 2025

History

History
141 lines (121 loc) · 9.17 KB

binary-search-problems.md

File metadata and controls

141 lines (121 loc) · 9.17 KB

Basic

Problem Difficulty
704. Binary Search Easy
374. Guess Number Higher or Lower Easy
2300. Successful Pairs of Spells and Potions Medium (1476)
@@2779. Maximum Beauty of an Array After Applying Operation Medium (1638)
@@826. Most Profit Assigning Work Medium (1708)

Search the First/Last Position

Or find the lower/upper bound of a target.

Problem Difficulty
278. First Bad Version Easy
35. Search Insert Position Easy
34. Find First and Last Position of Element in Sorted Array Medium
@@475. Heaters Medium
@@611. Valid Triangle Number Medium
1855. Maximum Distance Between a Pair of Values Medium (1514)
2563. Count the Number of Fair Pairs Medium (1720)

Search on Value

Minimum Value

  • "Search the First/Last Position" is the prerequisite of "Search on Value".
  • This also includes "minimize the maximum value". I order these problems by similarity, not by difficulty.
Problem Difficulty
875. Koko Eating Bananas Medium (1766)
@@1011. Capacity To Ship Packages Within D Days Medium (1725)
@@410. Split Array Largest Sum Hard
1760. Minimum Limit of Balls in a Bag Medium (1940)
@@2187. Minimum Time to Complete Trips Medium (1640)
2594. Minimum Time to Repair Cars Medium (1915)
1283. Find the Smallest Divisor Given a Threshold Medium (1542)
@@2064. Minimized Maximum of Products Distributed to Any Store Medium (1886)
1870. Minimum Speed to Arrive on Time Medium (1676)
@@1482. Minimum Number of Days to Make m Bouquets Medium (1945)
2439. Minimize Maximum of Array Medium (1965)
2560. House Robber IV Medium (2081)
@@1631. Path With Minimum Effort Medium (1947)

Maximum Value

This also includes maximize the minimum value.

Problem Difficulty
@@2226. Maximum Candies Allocated to K Children Medium (1646)
@@1552. Magnetic Force Between Two Balls Medium (1919)

Kth Smallest/Largest Element

Problem Difficulty
378. Kth Smallest Element in a Sorted Matrix Medium
@@373. Find K Pairs with Smallest Sums Medium

Some can be solved by heap. Consider to merge this section with heap problems.

Search in Matrix

Problem Difficulty
74. Search a 2D Matrix Medium
1351. Count Negative Numbers in a Sorted Matrix Easy
240. Search a 2D Matrix II Medium

Design

Problem Difficulty
729. My Calendar I Medium
981. Time Based Key-Value Store Medium
@@1146. Snapshot Array Medium (1770)

Rotated Array

Problem Difficulty
33. Search in Rotated Sorted Array Medium
153. Find Minimum in Rotated Sorted Array Medium

Other

Problem Difficulty
69. Sqrt(x) Easy
@@633. Sum of Square Numbers Medium
162. Find Peak Element Medium
1095. Find in Mountain Array Hard (1827)
287. Find the Duplicate Number Medium
540. Single Element in a Sorted Array Medium

Explanation