TEAMUnregistered
Problemset/

Two Sum

Easy

Two Sum

EasyPoints: 100Time Limit: 2s

Given an array of integers nums and an integer target, return the 0-based indices of the two numbers such that they add up to target.

Input Format

  • First line contains integer N.
  • Second line contains N space-separated integers nums[i].
  • Third line contains integer target.

Output Format

  • Print two space-separated integers: index 1 and index 2.

Constraints

  • 2 <= N <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • -10^9 <= target <= 10^9

Sample Test Cases

Case 1
Input:
4
2 7 11 15
9
Expected Output:
0 1
Case 2
Input:
3
3 2 4
6
Expected Output:
1 2
solution.py
python · UTF-8
Ln 1, Col 1·1 lines
Spaces: 4• Ready