Beginner · 20 XP
Two Sum in Linear Time
Given an array of integers `nums` and an integer `target`, return the indices of the two numbers such that they add up to `target`. ### Constraints: - Exactly one valid solution exists. - Time complexity must be O(N) using a dictionary lookup table.
Show Step-by-Step Hint
- • As you iterate, calculate `complement = target - num`.
- • Check if `complement` is already in your dictionary.
Type: Code Challenge
Runtime: PYTHON
PYTHON solutionCHALLENGE #4