DeepFrontend
Practice ArenaBlogSign in
Go Pro
DeepFrontend

Interview-grade learning paths and hands-on practice for mid-to-senior engineers. Master internals, patterns, and system architecture with runnable code.

All systems operational

Core Courses

  • -JavaScript Internals
  • -React Reconciliation
  • -TypeScript rigor
  • -Next.js Caching
  • -Node.js Event Loop
  • -System Design
  • -Web Security
  • -CSS & Page Layouts

Explore

  • Learning Paths
  • Practice Arena
  • Pricing Options
  • HTML Sitemap

Resources

  • Privacy Policy
  • Terms of Service
  • Email Support

© 2026 DeepFrontend. All rights reserved.

Expert learning environments for web engineering teams.

← All challenges
warmup12 min

Binary Search

Binary Search

Given a sorted ascending array nums and a target, return the index of target, or -1 if it's absent. Must run in O(log n) — the whole point is to halve the search space each step.

The classic pitfalls interviewers watch for: computing mid without overflow, and getting the lo <= hi loop boundary right so you don't skip or infinite-loop.

binarySearch([-1, 0, 3, 5, 9, 12], 9);  // 4
binarySearch([-1, 0, 3, 5, 9, 12], 2);  // -1

Run your code to see results.

Stuck? This challenge exercises:

javascript.data-structures