ProblemsArraysTwo SumEasy
1/45
00:01

Two Sum

EasyAmazonGoogleTCS

Given an array of N integers and a target, find two numbers that add up to the target. Print their indices (0-based).

Input Format

First line: N (size)
Second line: N space-separated integers
Third line: target

Output Format

Two space-separated indices

Example 1

INPUT

4
2 7 11 15
9

OUTPUT

0 1

nums[0]+nums[1] = 2+7 = 9

Example 2

INPUT

3
3 2 4
6

OUTPUT

1 2

Constraints

• 2 ≤ N ≤ 10⁴

• -10⁹ ≤ nums[i] ≤ 10⁹

Language
FirstGrade Code Editor
Ctrl+Enter: RunCtrl+Shift+Enter: SubmitPython 3