Easy
PY-001pythonTwo Sum (Banking)
Problem
You're auditing a set of transaction amounts and need to find two transactions that together reconcile to exactly `target`. Return the 0-based indices of the two transactions. Exactly one solution exists.
Input
First line: integer n and target separated by space. Second line: n space-separated integers.
Output
Two 0-based indices separated by a space.
Constraints
2 ≤ n ≤ 10^5, -10^9 ≤ nums[i] ≤ 10^9, -10^9 ≤ target ≤ 10^9
Sample input
4 9 2 7 11 15
Sample output
0 1
Explanation
2 + 7 == 9 → indices 0 and 1.
hash-maparraysbasics@Google@Amazon@Microsoft
Visible test cases
in: 4 9 2 7 11 15
out: 0 1
in: 3 6 3 2 4
out: 1 2
Your solution — run it, use AI if stuck
python
