Binary Search Problems
265 Binary Search LeetCode problems · Solve with AI-powered hints & step-by-step explanations.
Learn the coding interview patterns behind these problems, including Binary Search interview patterns.
Start with these
All Binary Search problems
4 Median of Two Sorted Arrays Hard33 Search in Rotated Sorted Array Medium34 Find First and Last Position of Element in Sorted Array Medium35 Search Insert Position Easy69 Sqrt(x) Easy74 Search a 2D Matrix Medium81 Search in Rotated Sorted Array II Medium153 Find Minimum in Rotated Sorted Array Medium154 Find Minimum in Rotated Sorted Array II Hard162 Find Peak Element Medium167 Two Sum II - Input Array Is Sorted Medium209 Minimum Size Subarray Sum Medium222 Count Complete Tree Nodes Easy240 Search a 2D Matrix II Medium268 Missing Number Easy275 H-Index II Medium278 First Bad Version Easy287 Find the Duplicate Number Medium300 Longest Increasing Subsequence Medium315 Count of Smaller Numbers After Self Hard327 Count of Range Sum Hard349 Intersection of Two Arrays Easy350 Intersection of Two Arrays II Easy352 Data Stream as Disjoint Intervals Hard354 Russian Doll Envelopes Hard363 Max Sum of Rectangle No Larger Than K Hard367 Valid Perfect Square Easy374 Guess Number Higher or Lower Easy378 Kth Smallest Element in a Sorted Matrix Medium400 Nth Digit Medium410 Split Array Largest Sum Hard441 Arranging Coins Easy456 132 Pattern Medium475 Heaters Medium483 Smallest Good Base Hard493 Reverse Pairs Hard497 Random Point in Non-overlapping Rectangles Medium528 Random Pick with Weight Medium532 K-diff Pairs in an Array Medium540 Single Element in a Sorted Array Medium611 Valid Triangle Number Medium633 Sum of Square Numbers Medium658 Find K Closest Elements Medium668 Kth Smallest Number in Multiplication Table Hard704 Binary Search Easy710 Random Pick with Blacklist Hard713 Subarray Product Less Than K Medium718 Maximum Length of Repeated Subarray Medium719 Find K-th Smallest Pair Distance Hard729 My Calendar I Medium731 My Calendar II Medium732 My Calendar III Hard744 Find Smallest Letter Greater Than Target Easy754 Reach a Number Medium778 Swim in Rising Water Hard786 K-th Smallest Prime Fraction Medium792 Number of Matching Subsequences Medium793 Preimage Size of Factorial Zeroes Function Hard825 Friends Of Appropriate Ages Medium826 Most Profit Assigning Work Medium852 Peak Index in a Mountain Array Medium862 Shortest Subarray with Sum at Least K Hard875 Koko Eating Bananas Medium878 Nth Magical Number Hard887 Super Egg Drop Hard888 Fair Candy Swap Easy902 Numbers At Most N Given Digit Set Hard911 Online Election Medium981 Time Based Key-Value Store Medium1004 Max Consecutive Ones III Medium1011 Capacity To Ship Packages Within D Days Medium1027 Longest Arithmetic Subsequence Medium1044 Longest Duplicate Substring Hard1095 Find in Mountain Array Hard1146 Snapshot Array Medium1157 Online Majority Element In Subarray Hard1170 Compare Strings by Frequency of the Smallest Character Medium1187 Make Array Strictly Increasing Hard1201 Ugly Number III Medium1208 Get Equal Substrings Within Budget Medium1235 Maximum Profit in Job Scheduling Hard1237 Find Positive Integer Solution for a Given Equation Medium1268 Search Suggestions System Medium1283 Find the Smallest Divisor Given a Threshold Medium1292 Maximum Side Length of a Square with Sum Less than or Equal to Threshold Medium1300 Sum of Mutated Array Closest to Target Medium1337 The K Weakest Rows in a Matrix Easy1346 Check If N and Its Double Exist Easy1348 Tweet Counts Per Frequency Medium1351 Count Negative Numbers in a Sorted Matrix Easy1385 Find the Distance Value Between Two Arrays Easy1439 Find the Kth Smallest Sum of a Matrix With Sorted Rows Hard1477 Find Two Non-overlapping Sub-arrays Each With Target Sum Medium1482 Minimum Number of Days to Make m Bouquets Medium1483 Kth Ancestor of a Tree Node Hard1488 Avoid Flood in The City Medium1498 Number of Subsequences That Satisfy the Given Sum Condition Medium1508 Range Sum of Sorted Subarray Sums Medium1521 Find a Value of a Mysterious Function Closest to Target Hard1539 Kth Missing Positive Number Easy1552 Magnetic Force Between Two Balls Medium1562 Find Latest Group of Size M Medium1574 Shortest Subarray to be Removed to Make Array Sorted Medium1608 Special Array With X Elements Greater Than or Equal X Easy1631 Path With Minimum Effort Medium1648 Sell Diminishing-Valued Colored Balls Medium1649 Create Sorted Array through Instructions Hard1658 Minimum Operations to Reduce X to Zero Medium1671 Minimum Number of Removals to Make Mountain Array Hard1712 Ways to Split Array Into Three Subarrays Medium1713 Minimum Operations to Make a Subsequence Hard1739 Building Boxes Hard1751 Maximum Number of Events That Can Be Attended II Hard1760 Minimum Limit of Balls in a Bag Medium1782 Count Pairs Of Nodes Hard1793 Maximum Score of a Good Subarray Hard1802 Maximum Value at a Given Index in a Bounded Array Medium1818 Minimum Absolute Sum Difference Medium1838 Frequency of the Most Frequent Element Medium1847 Closest Room Hard1851 Minimum Interval to Include Each Query Hard1855 Maximum Distance Between a Pair of Values Medium1862 Sum of Floored Pairs Hard1870 Minimum Speed to Arrive on Time Medium1889 Minimum Space Wasted From Packaging Hard1894 Find the Student that Will Replace the Chalk Medium1898 Maximum Number of Removable Characters Medium1901 Find a Peak Element II Medium1923 Longest Common Subpath Hard1932 Merge BSTs to Create Single BST Hard1954 Minimum Garden Perimeter to Collect Enough Apples Medium1964 Find the Longest Valid Obstacle Course at Each Position Hard1970 Last Day Where You Can Still Cross Hard2008 Maximum Earnings From Taxi Medium2009 Minimum Number of Operations to Make Array Continuous Hard2024 Maximize the Confusion of an Exam Medium2035 Partition Array Into Two Arrays to Minimize Sum Difference Hard2040 Kth Smallest Product of Two Sorted Arrays Hard2054 Two Best Non-Overlapping Events Medium2055 Plates Between Candles Medium2064 Minimized Maximum of Products Distributed to Any Store Medium2070 Most Beautiful Item for Each Query Medium2071 Maximum Number of Tasks You Can Assign Hard2080 Range Frequency Queries Medium2089 Find Target Indices After Sorting Array Easy2106 Maximum Fruits Harvested After at Most K Steps Hard2111 Minimum Operations to Make the Array K-Increasing Hard2141 Maximum Running Time of N Computers Hard2179 Count Good Triplets in an Array Hard2187 Minimum Time to Complete Trips Medium2223 Sum of Scores of Built Strings Hard2226 Maximum Candies Allocated to K Children Medium2234 Maximum Total Beauty of the Gardens Hard2250 Count Number of Rectangles Containing Each Point Medium2251 Number of Flowers in Full Bloom Hard2258 Escape the Spreading Fire Hard2271 Maximum White Tiles Covered by a Carpet Medium2286 Booking Concert Tickets in Groups Hard2300 Successful Pairs of Spells and Potions Medium2302 Count Subarrays With Score Less Than K Hard2332 The Latest Time to Catch a Bus Medium2333 Minimum Sum of Squared Difference Medium2354 Number of Excellent Pairs Hard2358 Maximum Number of Groups Entering a Competition Medium2389 Longest Subsequence With Limited Sum Easy2398 Maximum Number of Robots Within Budget Hard2411 Smallest Subarrays With Maximum Bitwise OR Medium2424 Longest Uploaded Prefix Medium2426 Number of Pairs Satisfying Inequality Hard2439 Minimize Maximum of Array Medium2448 Minimum Cost to Make Array Equal Hard2454 Next Greater Element IV Hard2468 Split Message Based on Limit Hard2476 Closest Nodes Queries in a Binary Search Tree Medium2498 Frog Jump II Medium2501 Longest Square Streak in an Array Medium2513 Minimize the Maximum of Two Arrays Medium2517 Maximum Tastiness of Candy Basket Medium2528 Maximize the Minimum Powered City Hard2529 Maximum Count of Positive Integer and Negative Integer Easy2540 Minimum Common Value Easy2554 Maximum Number of Integers to Choose From a Range I Medium2555 Maximize Win From Two Segments Medium2560 House Robber IV Medium2563 Count the Number of Fair Pairs Medium2565 Subsequence With the Minimum Score Hard2576 Find the Maximum Number of Marked Indices Medium2589 Minimum Time to Complete All Tasks Hard2594 Minimum Time to Repair Cars Medium2601 Prime Subtraction Operation Medium2602 Minimum Operations to Make All Array Elements Equal Medium2616 Minimize the Maximum Difference of Pairs Medium2659 Make Array Empty Hard2713 Maximum Strictly Increasing Cells in a Matrix Hard2736 Maximum Sum Queries Hard2779 Maximum Beauty of an Array After Applying Operation Medium2790 Maximum Number of Groups With Increasing Length Hard2812 Find the Safest Path in a Grid Medium2817 Minimum Absolute Difference Between Elements With Constraint Medium2824 Count Pairs Whose Sum is Less than Target Easy2826 Sorting Three Groups Medium2830 Maximize the Profit as the Salesman Medium2831 Find the Longest Equal Subarray Medium2856 Minimum Array Length After Pair Removals Medium2861 Maximum Number of Alloys Medium2926 Maximum Balanced Subsequence Sum Hard2940 Find Building Where Alice and Bob Can Meet Hard2945 Find Maximum Non-decreasing Array Length Hard2967 Minimum Cost to Make Array Equalindromic Medium2968 Apply Operations to Maximize Frequency Score Hard2970 Count the Number of Incremovable Subarrays I Easy2972 Count the Number of Incremovable Subarrays II Hard2981 Find Longest Special Substring That Occurs Thrice I Medium2982 Find Longest Special Substring That Occurs Thrice II Medium3006 Find Beautiful Indices in the Given Array I Medium3007 Maximum Number That Sum of the Prices Is Less Than or Equal to K Medium3008 Find Beautiful Indices in the Given Array II Hard3048 Earliest Second to Mark Indices I Medium3049 Earliest Second to Mark Indices II Hard3113 Find the Number of Subarrays Where Boundary Elements Are Maximum Hard3116 Kth Smallest Amount With Single Denomination Combination Hard3117 Minimum Sum of Values by Dividing Array Hard3134 Find the Median of the Uniqueness Array Hard3143 Maximum Points Inside the Square Medium3145 Find Products of Elements of Big Array Hard3152 Special Array II Medium3161 Block Placement Queries Hard3171 Find Subarray With Bitwise OR Closest to K Hard3186 Maximum Total Damage With Spell Casting Medium3209 Number of Subarrays With AND Value of K Hard3261 Count Substrings That Satisfy K-Constraint II Hard3281 Maximize Score of Numbers in Ranges Medium3288 Length of the Longest Increasing Path Hard3291 Minimum Number of Valid Strings to Form Target I Medium3292 Minimum Number of Valid Strings to Form Target II Hard3296 Minimum Number of Seconds to Make Mountain Height Zero Medium3312 Sorted GCD Pair Queries Hard3346 Maximum Frequency of an Element After Performing Operations I Medium3347 Maximum Frequency of an Element After Performing Operations II Hard3350 Adjacent Increasing Subarrays Detection II Medium3356 Zero Array Transformation II Medium3357 Minimize the Maximum Adjacent Element Difference Hard3398 Smallest Substring With Identical Characters I Hard3399 Smallest Substring With Identical Characters II Hard3413 Maximum Coins From K Consecutive Bags Medium3414 Maximum Score of Non-overlapping Intervals Hard3419 Minimize the Maximum Edge Weight of Graph Medium3449 Maximize the Minimum Game Score Hard3453 Separate Squares I Medium3454 Separate Squares II Hard3455 Shortest Matching Substring Hard3464 Maximize the Distance Between Points on a Square Hard3477 Fruits Into Baskets II Easy3479 Fruits Into Baskets III Medium3488 Closest Equal Element Queries Medium3501 Maximize Active Section with Trade II Hard3508 Implement Router Medium3532 Path Existence Queries in a Graph I Medium3534 Path Existence Queries in a Graph II Hard3585 Find Weighted Median Node in Tree Hard3600 Maximize Spanning Tree Stability with Upgrades Hard3605 Minimum Stability Factor of Array Hard3608 Minimum Time for K Connected Components Medium3613 Minimize Maximum Component Cost Medium3620 Network Recovery Pathways Hard