Pattern · Binary Search

Binary Search interview questions

181 binary search problems tagged across recent interview reports. Drilled most heavily by google, meta, and microsoft.

Founder's read

Binary Search is the go-to pattern for solving search and optimization problems on sorted arrays or search spaces in 181 problems across platforms. The pattern cuts problem size in half per step, O(log n) instead of O(n), and it's a staple at Google (49 problems), Meta (45), and Microsoft (44). Most candidates drill it early but freeze on variants: recognizing when to binary search on the answer rather than the array, handling edge cases in the left/right boundary, or combining it with constraints like "ship all packages in D days." If a hard Binary Search problem lands in your live OA, StealthCoder solves it in seconds, invisible to the proctor.

Most-asked binary search problems

#ProblemDiff# Companies
01Find First and Last Position of Element in Sorted ArrayMEDIUM31
02Find Peak ElementMEDIUM24
03Find Minimum in Rotated Sorted ArrayMEDIUM19
04Design Hit CounterMEDIUM16
05Find the Duplicate NumberMEDIUM12
06Capacity To Ship Packages Within D DaysMEDIUM10
07Binary SearchEASY7
08Block Placement QueriesHARD7
09Find K Closest ElementsMEDIUM7
10Find the Safest Path in a GridMEDIUM3
11132 PatternMEDIUM2
123Sum SmallerMEDIUM2
13Apply Operations to Maximize Frequency ScoreHARD2
14Closest Binary Search Tree ValueEASY2
15Count Pairs in Two ArraysMEDIUM2
16Count Pairs Whose Sum is Less than TargetEASY2
17Count the Number of Fair PairsMEDIUM2
18Count the Number of Incremovable Subarrays IIHARD2
19Fair Candy SwapEASY2
20Find Beautiful Indices in the Given Array IMEDIUM2
21Find Beautiful Indices in the Given Array IIHARD2
22Find K-th Smallest Pair DistanceHARD2
23Find the Longest Equal SubarrayMEDIUM2
24Arranging CoinsEASY1
25Avoid Flood in The CityMEDIUM1
26Check If a Number Is Majority Element in a Sorted ArrayEASY1
27Closest Equal Element QueriesMEDIUM1
28Count Complete Tree NodesEASY1
29Count Good Triplets in an ArrayHARD1
30Count of Range SumHARD1
31Count of Smaller Numbers After SelfHARD1
32Count Subarrays With Score Less Than KHARD1
33Create Sorted Array through InstructionsHARD1
34Cutting RibbonsMEDIUM1
35Data Stream as Disjoint IntervalsHARD1
36Earliest Second to Mark Indices IMEDIUM1
37Earliest Second to Mark Indices IIHARD1
38Escape the Spreading FireHARD1
39Find a Peak Element IIMEDIUM1
40Find a Value of a Mysterious Function Closest to TargetHARD1
41Find Building Where Alice and Bob Can MeetHARD1
42Find in Mountain ArrayHARD1
43Find Longest Special Substring That Occurs Thrice IIMEDIUM1
44Find Minimum in Rotated Sorted Array IIHARD1
45Find Products of Elements of Big ArrayHARD1
46Find Smallest Letter Greater Than TargetEASY1
47Find Subarray With Bitwise OR Closest to KHARD1
48Find Target Indices After Sorting ArrayEASY1
49Find the Distance Value Between Two ArraysEASY1
50Find the Longest Valid Obstacle Course at Each PositionHARD1

Showing top 50 of 181 binary search problems by # companies asking.

The hedge for the live OA

You can't drill every binary search variant before the assessment. StealthCoder runs invisibly during screen share and solves whichever variant they throw at you. No browser extension. No detection signature. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

Binary Search problems fall into two camps: searching a sorted structure directly (array, tree, or matrix) and searching the answer space when you need to find the minimum or maximum value that satisfies a condition. Most candidates spot the first type but miss the second, problems like Capacity to Ship Packages or Arranging Coins require you to binary search on the range of possible answers, not a given array. The trick is recognizing the monotonic property: if X works, all values above X work (or below, depending on the condition). Top companies, Goldman Sachs, LinkedIn, TikTok, Amazon, PayPal, lean hard on the answer-space variants because they test whether you can model the constraint correctly. Common pitfalls: off-by-one errors in mid calculation, forgetting to handle duplicates, and not defining the search space bounds clearly. StealthCoder is the hedge for the tricky variant you didn't drill, the one where the answer space isn't obvious or the boundary logic gets messy in the live setting.

Companies that hire most on binary search

The honest play

181 binary search problems. You won't drill them all. Pass anyway.

Binary Search is one of the patterns interviews actually filter on. Memorizing every variant in a week is a fantasy. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds, no matter which binary search flavor lands in your live OA. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Binary Search interview FAQ

How do I recognize a Binary Search problem on sight?+

Look for a sorted array or a monotonic property, if you can determine a boundary where all values on one side satisfy a condition and all on the other don't, it's searchable. Problems like Check If a Number Is Majority Element are direct. Harder ones like Avoid Flood in the City hide the search space in the problem logic, not the input structure.

Should I drill answer-space Binary Search separately?+

Yes. Answer-space problems (find the minimum days to complete X, the maximum capacity, etc.) are conceptually the same but require you to define the search bounds and write the condition logic first. Capacity to Ship Packages Within D Days is the canonical example. They appear in 30+ problems at companies like Google and Amazon.

Which company drills Binary Search the hardest?+

Google leads with 49 problems tagged Binary Search, followed by Meta (45) and Microsoft (44). Goldman Sachs, LinkedIn, and TikTok each have 37. The problems span difficulty levels, but expect multiple rounds to include a variant.

What's the most common mistake on Binary Search problems?+

Off-by-one errors in the left or right boundary. Candidates often forget whether the search should be left < right or left <= right, or they return mid instead of lo/hi. Write out the invariant clearly: what does lo and hi represent at the end of the loop.

Can I skip Binary Search in interview prep?+

Not if you're targeting top companies. 181 problems are tagged with it, and Google, Meta, and Microsoft will test it. Even if the obvious approach doesn't need it, a follow-up asking for O(log n) time will. Core problems like binary-search and arranging-coins are non-negotiable.

Problem and frequency data sourced from public community-maintained interview-report repos. Problems and trademarks © LeetCode.