PROBLEMS|MOD 07|MEDIUM

Two Sum

Lists & Tuples

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

// EXAMPLES

Example 1:
Input: Input: [2, 7, 11, 15], 9
Output: [0, 1]
Explanation: Result for example 1 of Two Sum.
Example 2:
Input: Input: [3, 2, 4], 6
Output: [1, 2]
Explanation: Result for example 2 of Two Sum.

// CONSTRAINTS

  • -10^9 <= n <= 10^9
  • Time Complexity target: O(N) or O(N log N)
  • Space Complexity target: O(1) or O(N)
  • Evaluated against 600 test cases.
solution.py