Skip to interview prep
Apexed

1. Fix the binary search

EasyDebugging & productionDebugging

This binary search sometimes returns -1 for values that are in the array. Find and fix the bug.

Example 1

Input: search([1, 3, 5, 7], 7)
Output: 3

Constraints

  • Fix the bug; keep the function signature

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Fix the binary search — coding interview practice — Apexed