All questions
EasyArrays · Hash Map
Alien Two Sum
Written by a community member · · 1 attempt · 0% pass
0
You are given a list of integers nums and an integer target. Return the indices of the two numbers such that they add up to target.
Assume there is exactly one valid answer, and you may not use the same element twice. Return the indices in ascending order.
Examples:
nums = [2, 7, 11, 15], target = 9->[0, 1]nums = [3, 2, 4], target = 6->[1, 2]
Follow-up: Can you solve it in one pass using a hash map?