root@coding-prodigies:~#
← All challenges

Two Sum

A classic interview question: find two numbers that add up to a target.

🟡 MediumDifficulty

The challenge

Given [2, 7, 11, 15] and a target of 9, find the two indices whose values add up to the target and print them separated by a space (e.g. 0 1).

There's exactly one valid pair.

Output

  
🧠 Need a hint? (Python)

The brute-force approach works fine here: two nested loops checking every pair of indices until arr[i] + arr[j] == target.

🚀

Like solving these?

Structured courses, hands-on exercises, and real multi-file projects are waiting -- your first project unlock is free.

Create a free account

More challenges