Easy · spoken drill

How to Explain Binary Search in English

Binary search is a “sorted, so I can discard half” story. Say left and right, compare the mid, and keep the half that can still contain the target.

The problem

Given a sorted array of integers nums, in ascending order, and an integer target, return the index of target if it exists, or -1 if it does not. You should write an algorithm with O(log n) runtime.

Say why sorted matters, then narrate left, right, and mid. Do not skip the “I discard this half” sentence.

left, right = 0, len(nums) - 1
while left <= right:
    mid = (left + right) // 2
    if nums[mid] == target:
        return mid
    if nums[mid] < target:
        left = mid + 1
    else:
        right = mid - 1
return -1

How to explain it

  1. 1. Restate

    Say the problem in your own words.

    One or two sentences. Show you understood the input, the output, and the goal — not that you memorised the prompt.

  2. 2. Approach

    Name the method before you code.

    Brute force first if you need it, then the structure you will use: hash map, two pointers, stack, binary search.

  3. 3. Example

    Walk one concrete input.

    Pick small numbers. Say what you store, what you compare, and what you return. Interviewers follow an example more easily than abstract talk.

  4. 4. Time and space

    One sentence each.

    After the example, before you claim you are done. “Time is O(n) because we scan once. Space is O(n) for the map.”

  5. 5. Edge cases

    Name at least one unusual input.

    Empty input, duplicates, already sorted, overflow. Invite a follow-up: “I would also check …”

  • “Because the array is sorted I can discard half each step.”
  • “I keep a left and a right index and look at the middle.”
  • “Time is O(log n). Space is O(1).”
  • “If the mid is too small, I move left up.”

Practise out loud

Record 60–90 seconds. Play it back, then get a scorecard. Audio is scored and discarded.

This browser cannot record audio. Type your explanation below.

0:00 / 1:30

Model spoken script

Let me restate this. The array is sorted, and I need the index of the target, or minus one. Because it is sorted I can use binary search and discard half the range each step. I keep a left and a right index. I look at the middle. If the mid is the target, I return it. If the mid is smaller, I move left up. If it is larger, I move right down. For example, 1, 3, 5, 7, 9, target 7. Mid is 5, too small, so I search the right half, then I hit 7. Time is O(log n). Space is O(1). I would check an empty array and the case where the target is smaller than the first element.

Other problems

FAQ

Questions

Say the array is sorted, so you can discard half. Narrate left, right, and mid, walk one example, then say O(log n) time and O(1) space.

More questions? Email us at contact@mocklyenglish.com.

Course: How to explain a LeetCode solution · Think out loud · Explain code out loud

Quick answer

Explain a LeetCode solution in English with a fixed order: restate, name the approach, walk an example, state time and space, then name an edge case. Record 60–90 seconds and get a scorecard on that structure — not on your accent.

Free 30-minute trial

Take a mock interview

Get feedback on your answers and your English from certified coaches.

Sophie

5.0 · 159 reviews

Tom

5.0 · 156 reviews

No credit card needed