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

Two Sum

Two Sum

The single most-asked coding interview question. Given an array of integers nums and a target target, return the indices of the two numbers that add up to target. Exactly one solution exists, and you may not use the same element twice.

The naive answer is two nested loops (O(n²)). The answer they're looking for is one pass with a hash map (O(n)): for each number, check whether target - num is already in the map.

twoSum([2, 7, 11, 15], 9); // [0, 1]  (2 + 7)
twoSum([3, 2, 4], 6);      // [1, 2]  (2 + 4)

Run your code to see results.

Stuck? This challenge exercises:

javascript.data-structures