Binary Search Pattern

Halve the search space on sorted data or monotonic answer functions.

#Title
4Median of Two Sorted Arrays
33Search in Rotated Sorted Array
34Find First and Last Position of Element in Sorted Array
35Search Insert Position
69Sqrt(x)
74Search a 2D Matrix
81Search in Rotated Sorted Array II
153Find Minimum in Rotated Sorted Array
154Find Minimum in Rotated Sorted Array II
162Find Peak Element
209Minimum Size Subarray Sum
222Count Complete Tree Nodes
275H-Index II
278First Bad Version
287Find the Duplicate Number
300Longest Increasing Subsequence
302Smallest Rectangle Enclosing Black Pixels
349Intersection of Two Arrays
350Intersection of Two Arrays II
354Russian Doll Envelopes
363Max Sum of Rectangle No Larger Than K
367Valid Perfect Square
374Guess Number Higher or Lower
410Split Array Largest Sum
436Find Right Interval
441Arranging Coins
475Heaters
540Single Element in a Sorted Array
658Find K Closest Elements
668Kth Smallest Number in Multiplication Table
702Search in a Sorted Array of Unknown Size
704Binary Search
710Random Pick with Blacklist
718Maximum Length of Repeated Subarray
719Find K-th Smallest Pair Distance
744Find Smallest Letter Greater Than Target
774Minimize Max Distance to Gas Station
786K-th Smallest Prime Fraction
793Preimage Size of Factorial Zeroes Function
852Peak Index in a Mountain Array
875Koko Eating Bananas
878Nth Magical Number
894All Possible Full Binary Trees
911Online Election
981Time Based Key-Value Store
1011Capacity To Ship Packages Within D Days
1060Missing Element in Sorted Array
1064Fixed Point
1095Find in Mountain Array
1102Path With Maximum Minimum Value
1103Distribute Candies to People
1110Delete Nodes And Return Forest
1150Check If a Number Is Majority Element in a Sorted Array
1157Online Majority Element In Subarray
1170Compare Strings by Frequency of the Smallest Character
1201Ugly Number III
1215Stepping Numbers
1228Missing Number In Arithmetic Progression
1231Divide Chocolate
1274Number of Ships in a Rectangle
1283Find the Smallest Divisor Given a Threshold
1287Element Appearing More Than 25% In Sorted Array
1292Maximum Side Length of a Square with Sum Less than or Equal to Threshold
1300Sum of Mutated Array Closest to Target
1385Find the Distance Value Between Two Arrays
1439Find the Kth Smallest Sum of a Matrix With Sorted Rows
1482Minimum Number of Days to Make m Bouquets
1508Range Sum of Sorted Subarray Sums
1533Find the Index of the Large Integer
1539Kth Missing Positive Number
1552Magnetic Force Between Two Balls
1608Special Array With X Elements Greater Than or Equal X
1618Maximum Font to Fit a Sentence in a Screen
1631Path With Minimum Effort
1648Sell Diminishing-Valued Colored Balls
1671Minimum Number of Removals to Make Mountain Array
1713Minimum Operations to Make a Subsequence
1723Find Minimum Time to Finish All Jobs
1751Maximum Number of Events That Can Be Attended II
1760Minimum Limit of Balls in a Bag
1802Maximum Value at a Given Index in a Bounded Array
1818Minimum Absolute Sum Difference
1847Closest Room
1870Minimum Speed to Arrive on Time
1889Minimum Space Wasted From Packaging
1891Cutting Ribbons
1898Maximum Number of Removable Characters
1901Find a Peak Element II
1906Minimum Absolute Difference Queries
1918Kth Smallest Subarray Sum
1923Longest Common Subpath
1954Minimum Garden Perimeter to Collect Enough Apples
1956Minimum Time For K Virus Variants to Spread
1964Find the Longest Valid Obstacle Course at Each Position
2040Kth Smallest Product of Two Sorted Arrays
2048Next Greater Numerically Balanced Number
2064Minimized Maximum of Products Distributed to Any Store
2070Most Beautiful Item for Each Query
2071Maximum Number of Tasks You Can Assign
2080Range Frequency Queries
2111Minimum Operations to Make the Array K-Increasing
2137Pour Water Between Buckets to Make Water Levels Equal
2141Maximum Running Time of N Computers
2187Minimum Time to Complete Trips
2226Maximum Candies Allocated to K Children
2234Maximum Total Beauty of the Gardens
2250Count Number of Rectangles Containing Each Point
2251Number of Flowers in Full Bloom
2271Maximum White Tiles Covered by a Carpet
2286Booking Concert Tickets in Groups
2300Successful Pairs of Spells and Potions
2333Minimum Sum of Squared Difference
2387Median of a Row Wise Sorted Matrix
2389Longest Subsequence With Limited Sum
2426Number of Pairs Satisfying Inequality
2448Minimum Cost to Make Array Equal
2476Closest Nodes Queries in a Binary Search Tree
2503Maximum Number of Points From Grid Queries
2513Minimize the Maximum of Two Arrays
2517Maximum Tastiness of Candy Basket
2528Maximize the Minimum Powered City
2529Maximum Count of Positive Integer and Negative Integer
2554Maximum Number of Integers to Choose From a Range I
2557Maximum Number of Integers to Choose From a Range II
2560House Robber IV
2594Minimum Time to Repair Cars
2601Prime Subtraction Operation
2602Minimum Operations to Make All Array Elements Equal
2604Minimum Time to Eat All Grains
2616Minimize the Maximum Difference of Pairs
2702Minimum Operations to Make Numbers Non-positive
2735Collecting Chocolates
2736Maximum Sum Queries
2774Array Upper Bound
2790Maximum Number of Groups With Increasing Length
2812Find the Safest Path in a Grid
2817Minimum Absolute Difference Between Elements With Constraint
2819Minimum Relative Loss After Buying Chocolates
2861Maximum Number of Alloys
2907Maximum Profitable Triplets With Increasing Prices I
2921Maximum Profitable Triplets With Increasing Prices II
2926Maximum Balanced Subsequence Sum
2936Number of Equal Numbers Blocks
2940Find Building Where Alice and Bob Can Meet
2941Maximum GCD-Sum of a Subarray
2945Find Maximum Non-decreasing Array Length
2968Apply Operations to Maximize Frequency Score
3006Find Beautiful Indices in the Given Array I
3007Maximum Number That Sum of the Prices Is Less Than or Equal to K
3008Find Beautiful Indices in the Given Array II
3048Earliest Second to Mark Indices I
3049Earliest Second to Mark Indices II
3104Find Longest Self-Contained Substring
3116Kth Smallest Amount With Single Denomination Combination
3134Find the Median of the Uniqueness Array
3135Equalize Strings by Adding or Removing Characters at Ends
3145Find Products of Elements of Big Array
3197Find the Minimum Area to Cover All Ones II
3231Minimum Number of Increasing Subsequence to Be Removed
3233Find the Count of Numbers Which Are Not Special
3264Final Array State After K Multiplication Operations I
3266Final Array State After K Multiplication Operations II
3281Maximize Score of Numbers in Ranges
3288Length of the Longest Increasing Path
3296Minimum Number of Seconds to Make Mountain Height Zero
3312Sorted GCD Pair Queries
3344Maximum Sized Array
3356Zero Array Transformation II
3357Minimize the Maximum Adjacent Element Difference
3364Minimum Positive Sum Subarray
3398Smallest Substring With Identical Characters I
3399Smallest Substring With Identical Characters II
3414Maximum Score of Non-overlapping Intervals
3419Minimize the Maximum Edge Weight of Graph
3449Maximize the Minimum Game Score
3453Separate Squares I
3464Maximize the Distance Between Points on a Square
3477Fruits Into Baskets II
3479Fruits Into Baskets III
3489Zero Array Transformation IV
3520Minimum Threshold for Inversion Pairs Count
3574Maximize Subarray GCD Score
3585Find Weighted Median Node in Tree
3605Minimum Stability Factor of Array
3620Network Recovery Pathways
3646Next Special Palindrome Number
3709Design Exam Scores Tracker
3710Maximum Partition Factor
3719Longest Balanced Subarray I
3721Longest Balanced Subarray II
3722Lexicographically Smallest String After Reverse
3733Minimum Time to Complete All Deliveries
3735Lexicographically Smallest String After Reverse II
3762Minimum Operations to Equalize Subarrays
3770Largest Prime from Consecutive Prime Sum
3771Total Score of Dungeon Runs
3801Minimum Cost to Merge Sorted Lists
3807Minimum Cost to Repair Edges to Traverse a Graph
3814Maximum Capacity Within Budget
3824Minimum K to Reduce Array Within Limit
3825Longest Strictly Increasing Subsequence With Non-Zero Bitwise AND
3893Maximum Team Size with Overlapping Intervals
3896Count Digit Appearances
3911K-th Smallest Remaining Even Integer in Subarray Queries
3920Maximize Fixed Points After Deletions
3924Minimum Threshold Path With Limited Heavy Edges
3932Count K-th Roots in a Range
3934Smallest Unique Subarray
3971Maximum Total Value
3989Maximum Consistent Columns in a Grid