Back to Google
Google logo

Coding rounds

Google coding rounds

5 timed coding challenges drawn from real loops. Submit a solution to see your test pass rate and AI feedback.

All coding rounds
beginner 30:00+50 XP

Two Sum

Given an array of integers `nums` and an integer `target`, return the indices of the two numbers that add up to `target`. Each input has exactly one solution, and you may not use the same element twice. Aim for O(n) time using a hash map.

Examples

  • 2 + 7 = 9

    in: nums=[2,7,11,15], target=9

    out: [0,1]

  • 2 + 4 = 6

    in: nums=[3,2,4], target=6

    out: [1,2]

javascript
Loading editor...