Binary Search
76 problems
Binary search reduces search space by half each step, giving O(log n) time. Beyond sorted arrays, apply it on the answer space ("binary search on result") when you can define a monotonic predicate — e.g., "can we achieve X with k resources?"
- 4.Median of Two Sorted ArraysHard
- 33.Search in Rotated Sorted ArrayMedium
- 162.Find Peak ElementMedium
- 218.The Skyline ProblemHard
- 222.Count Complete Tree NodesMedium
- 278.First Bad VersionEasy
- 350.Intersection of Two Arrays IIEasy
- 352.Data Stream as Disjoint IntervalsUnknown
- 367.Valid Perfect SquareUnknown
- 611.Valid Triangle NumberMedium
- 633.Sum of Square NumbersMedium
- 658.Find K Closest ElementsMedium
- 719.Find K-th Smallest Pair DistanceHard
- 729.My Calendar IMedium
- 731.My Calendar IIUnknown
- 744.Find Smallest Letter Greater Than TargetEasy
- 825.Friends Of Appropriate AgesMedium
- 826.Most Profit Assigning WorkMedium
- 878.Nth Magical NumberHard
- 981.Time Based Key-Value StoreMedium
- 1011.Capacity To Ship Packages Within D DaysMedium
- 1346.Check If N and Its Double ExistUnknown
- 1482.Minimum Number of Days to Make m BouquetsMedium
- 1498.Number of Subsequences That Satisfy the Given Sum ConditionMedium
- 1508.Range Sum of Sorted Subarray SumsMedium
- 1552.Magnetic Force Between Two BallsMedium
- 1574.Shortest Subarray to be Removed to Make Array SortedUnknown
- 1671.Minimum Number of Removals to Make Mountain ArrayHard
- 1751.Maximum Number of Events That Can Be Attended IIUnknown
- 1760.Minimum Limit of Balls in a BagMedium
- 1802.Maximum Value at a Given Index in a Bounded ArrayHard
- 1862.Sum of Floored PairsUnknown
- 1894.Find the Student that Will Replace the ChalkUnknown
- 1938.Maximum Genetic Difference QueryUnknown
- 1970.Last Day Where You Can Still CrossUnknown
- 2008.Maximum Earnings From TaxiUnknown
- 2009.Minimum Number of Operations to Make Array ContinuousUnknown
- 2040.Kth Smallest Product of Two Sorted ArraysUnknown
- 2054.Two Best Non-Overlapping EventsUnknown
- 2064.Minimized Maximum of Products Distributed to Any StoreUnknown
- 2070.Most Beautiful Item for Each QueryMedium
- 2071.Maximum Number of Tasks You Can AssignUnknown
- 2106.Maximum Fruits Harvested After at Most K StepsUnknown
- 2141.Maximum Running Time of N ComputersUnknown
- 2226.Maximum Candies Allocated to K ChildrenMedium
- 2271.Maximum White Tiles Covered by a CarpetUnknown
- 2294.Partition Array Such That Maximum Difference Is KHard
- 2300.Successful Pairs of Spells and PotionsMedium
- 2302.Count Subarrays With Score Less Than KHard
- 2311.Longest Binary Subsequence Less Than or Equal to KMedium
- 2381.Shifting Letters IIMedium
- 2389.Longest Subsequence With Limited SumEasy
- 2501.Longest Square Streak in an ArrayMedium
- 2528.Maximize the Minimum Powered CityHard
- 2529.Maximum Count of Positive Integer and Negative IntegerEasy
- 2551.Put Marbles in BagsHard
- 2554.Maximum Number of Integers to Choose From a Range IMedium
- 2559.Count Vowel Strings in RangesMedium
- 2560.House Robber IVMedium
- 2563.Count the Number of Fair PairsMedium
- 2594.Minimum Time to Repair CarsUnknown
- 2601.Prime Subtraction OperationHard
- 2616.Minimize the Maximum Difference of PairsHard
- 2779.Maximum Beauty of an Array After Applying OperationUnknown
- 2940.Find Building Where Alice and Bob Can MeetUnknown
- 3013.Divide an Array Into Subarrays With Minimum Cost IIUnknown
- 3116.Kth Smallest Amount With Single Denomination CombinationMedium
- 3152.Special Array IIMedium
- 3346.Maximum Frequency of an Element After Performing Operations IMedium
- 3347.Maximum Frequency of an Element After Performing Operations IIUnknown
- 3356.Zero Array Transformation IIUnknown
- 3453.Separate Squares IUnknown
- 3454.Separate Squares IIUnknown
- 3477.Fruits Into Baskets IIMedium
- 3479.Fruits Into Baskets IIIUnknown
- 3578.Count Partitions With Max-Min Difference at Most KUnknown