Binary Search | LeetCode Problems

187 Binary Search solutions to LeetCode solutions.

Binary Search Problems View all solutions →

Median of Two Sorted Arrays

#4 Hard

Search in Rotated Sorted Array

#33 Medium

Find First and Last Position of Element in Sorted Array

#34 Medium

Search Insert Position

#35 Easy

Sqrt(x)

#69 Medium

Search a 2D Matrix

#74 Medium

Search in Rotated Sorted Array II

#81 Medium

Find Minimum in Rotated Sorted Array

#153 Medium

Find Minimum in Rotated Sorted Array II

#154 Hard

Find Peak Element

#162 Medium

Two Sum II - Input Array Is Sorted

#167 Easy

Minimum Size Subarray Sum

#209 Medium

Count Complete Tree Nodes

#222 Easy

Search a 2D Matrix II

#240 Medium

Missing Number

#268 Easy

H-Index II

#275 Medium

First Bad Version

#278 Medium

Find the Duplicate Number

#287 Medium

Longest Increasing Subsequence

#300 Medium

Count of Smaller Numbers After Self

#315 Hard

Count of Range Sum

#327 Hard

Intersection of Two Arrays

#349 Easy

Intersection of Two Arrays II

#350 Easy

Data Stream as Disjoint Intervals

#352 Hard

Russian Doll Envelopes

#354 Hard

Max Sum of Rectangle No Larger Than K

#363 Hard

Valid Perfect Square

#367 Easy

Guess Number Higher or Lower

#374 Medium

Kth Smallest Element in a Sorted Matrix

#378 Medium

Nth Digit

#400 Medium

Split Array Largest Sum

#410 Hard

Find Right Interval

#436 Medium

Arranging Coins

#441 Easy

132 Pattern

#456 Medium

Heaters

#475 Medium

Smallest Good Base

#483 Hard

Reverse Pairs

#493 Hard

Random Point in Non-overlapping Rectangles

#497 Medium

Random Pick with Weight

#528 Medium

K-diff Pairs in an Array

#532 Medium

Single Element in a Sorted Array

#540 Medium

Valid Triangle Number

#611 Medium

Sum of Square Numbers

#633 Medium

Find K Closest Elements

#658 Medium

Kth Smallest Number in Multiplication Table

#668 Hard

Binary Search

#704 Easy

Random Pick with Blacklist

#710 Hard

Subarray Product Less Than K

#713 Medium

Maximum Length of Repeated Subarray

#718 Medium

Find K-th Smallest Pair Distance

#719 Hard

My Calendar I

#729 Medium

My Calendar II

#731 Medium

My Calendar III

#732 Hard

Find Smallest Letter Greater Than Target

#744 Easy

Reach a Number

#754 Medium

Swim in Rising Water

#778 Hard

K-th Smallest Prime Fraction

#786 Medium

Number of Matching Subsequences

#792 Medium

Preimage Size of Factorial Zeroes Function

#793 Hard

Friends Of Appropriate Ages

#825 Medium

Most Profit Assigning Work

#826 Medium

Peak Index in a Mountain Array

#852 Medium

Shortest Subarray with Sum at Least K

#862 Hard

Koko Eating Bananas

#875 Medium

Nth Magical Number

#878 Hard

Super Egg Drop

#887 Hard

Fair Candy Swap

#888 Easy

Numbers At Most N Given Digit Set

#902 Hard

Online Election

#911 Medium

Time Based Key-Value Store

#981 Medium

Max Consecutive Ones III

#1004 Medium

Capacity To Ship Packages Within D Days

#1011 Medium

Longest Arithmetic Subsequence

#1027 Medium

Longest Duplicate Substring

#1044 Hard

Find in Mountain Array

#1095 Hard

Snapshot Array

#1146 Medium

Online Majority Element In Subarray

#1157 Hard

Compare Strings by Frequency of the Smallest Character

#1170 Medium

Make Array Strictly Increasing

#1187 Hard

Ugly Number III

#1201 Medium

Get Equal Substrings Within Budget

#1208 Medium

Maximum Profit in Job Scheduling

#1235 Hard

Find Positive Integer Solution for a Given Equation

#1237 Medium

Search Suggestions System

#1268 Medium

Find the Smallest Divisor Given a Threshold

#1283 Medium

Maximum Side Length of a Square with Sum Less than or Equal to Threshold

#1292 Medium

Sum of Mutated Array Closest to Target

#1300 Medium

The K Weakest Rows in a Matrix

#1337 Easy

Check If N and Its Double Exist

#1346 Easy

Tweet Counts Per Frequency

#1348 Medium

Count Negative Numbers in a Sorted Matrix

#1351 Easy

Find the Distance Value Between Two Arrays

#1385 Easy

Find the Kth Smallest Sum of a Matrix With Sorted Rows

#1439 Hard

Find Two Non-overlapping Sub-arrays Each With Target Sum

#1477 Medium

Minimum Number of Days to Make m Bouquets

#1482 Medium

Kth Ancestor of a Tree Node

#1483 Hard

Avoid Flood in The City

#1488 Medium

Number of Subsequences That Satisfy the Given Sum Condition

#1498 Medium

Range Sum of Sorted Subarray Sums

#1508 Medium

Find a Value of a Mysterious Function Closest to Target

#1521 Hard

Kth Missing Positive Number

#1539 Easy

Magnetic Force Between Two Balls

#1552 Medium

Find Latest Group of Size M

#1562 Medium

Shortest Subarray to be Removed to Make Array Sorted

#1574 Medium

Special Array With X Elements Greater Than or Equal X

#1608 Easy

Path With Minimum Effort

#1631 Medium

Sell Diminishing-Valued Colored Balls

#1648 Medium

Create Sorted Array through Instructions

#1649 Hard

Minimum Operations to Reduce X to Zero

#1658 Medium

Minimum Number of Removals to Make Mountain Array

#1671 Hard

Ways to Split Array Into Three Subarrays

#1712 Medium

Minimum Operations to Make a Subsequence

#1713 Hard

Building Boxes

#1739 Hard

Maximum Number of Events That Can Be Attended II

#1751 Hard

Minimum Limit of Balls in a Bag

#1760 Medium

Count Pairs Of Nodes

#1782 Hard

Maximum Score of a Good Subarray

#1793 Hard

Maximum Value at a Given Index in a Bounded Array

#1802 Medium

Minimum Absolute Sum Difference

#1818 Medium

Frequency of the Most Frequent Element

#1838 Medium

Closest Room

#1847 Hard

Minimum Interval to Include Each Query

#1851 Hard

Maximum Distance Between a Pair of Values

#1855 Medium

Sum of Floored Pairs

#1862 Hard

Minimum Speed to Arrive on Time

#1870 Medium

Minimum Space Wasted From Packaging

#1889 Hard

Find the Student that Will Replace the Chalk

#1894 Medium

Maximum Number of Removable Characters

#1898 Medium

Find a Peak Element II

#1901 Medium

Longest Common Subpath

#1923 Hard

Merge BSTs to Create Single BST

#1932 Hard

Minimum Garden Perimeter to Collect Enough Apples

#1954 Medium

Find the Longest Valid Obstacle Course at Each Position

#1964 Hard

Last Day Where You Can Still Cross

#1970 Hard

Maximum Earnings From Taxi

#2008 Medium

Minimum Number of Operations to Make Array Continuous

#2009 Hard

Maximize the Confusion of an Exam

#2024 Medium

Partition Array Into Two Arrays to Minimize Sum Difference

#2035 Hard

Kth Smallest Product of Two Sorted Arrays

#2040 Hard

Plates Between Candles

#2055 Medium

Minimized Maximum of Products Distributed to Any Store

#2064 Medium

Most Beautiful Item for Each Query

#2070 Medium

Maximum Number of Tasks You Can Assign

#2071 Hard

Range Frequency Queries

#2080 Medium

Find Target Indices After Sorting Array

#2089 Easy

Maximum Fruits Harvested After at Most K Steps

#2106 Hard

Minimum Operations to Make the Array K-Increasing

#2111 Hard

Maximum Running Time of N Computers

#2141 Hard

Count Good Triplets in an Array

#2179 Hard

Minimum Time to Complete Trips

#2187 Medium

Sum of Scores of Built Strings

#2223 Hard

Maximum Candies Allocated to K Children

#2226 Medium

Maximum Total Beauty of the Gardens

#2234 Hard

Count Number of Rectangles Containing Each Point

#2250 Medium

Number of Flowers in Full Bloom

#2251 Hard

Escape the Spreading Fire

#2258 Hard

Maximum White Tiles Covered by a Carpet

#2271 Medium

Successful Pairs of Spells and Potions

#2300 Medium

Count Subarrays With Score Less Than K

#2302 Hard

Number of Excellent Pairs

#2354 Hard

Maximum Number of Groups Entering a Competition

#2358 Medium

Longest Subsequence With Limited Sum

#2389 Easy

Smallest Subarrays With Maximum Bitwise OR

#2411 Medium

Number of Pairs Satisfying Inequality

#2426 Hard

Minimize Maximum of Array

#2439 Medium

Minimum Cost to Make Array Equal

#2448 Hard

Split Message Based on Limit

#2468 Hard

Closest Nodes Queries in a Binary Search Tree

#2476 Medium

Frog Jump II

#2498 Medium

Longest Square Streak in an Array

#2501 Medium

Maximum Tastiness of Candy Basket

#2517 Medium

Maximum Count of Positive Integer and Negative Integer

#2529 Easy

Minimum Common Value

#2540 Easy

Maximum Number of Integers to Choose From a Range I

#2554 Medium

House Robber IV

#2560 Medium

Count the Number of Fair Pairs

#2563 Medium

Find the Maximum Number of Marked Indices

#2576 Medium

Minimum Time to Repair Cars

#2594 Medium

Prime Subtraction Operation

#2601 Medium

Minimize the Maximum Difference of Pairs

#2616 Medium

Maximum Beauty of an Array After Applying Operation

#2779 Medium

Count Pairs Whose Sum is Less than Target

#2824 Easy

Sorting Three Groups

#2826 Medium

Count the Number of Incremovable Subarrays I

#2970 Easy

Find Longest Special Substring That Occurs Thrice I

#2981 Medium

Zero Array Transformation II

#3356 Medium

Maximize the Distance Between Points on a Square

#3464 Hard