Your question is 2Sum With Hash Map. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Cerebras data-processing pipeline receives an unsorted array of integer measurements. Given nums and an integer target, return the indices of two distinct elements whose values sum to target.
Use a hash map to avoid checking every pair. Return the indices in ascending order of discovery. Each input is guaranteed to contain exactly one valid pair, and the same array element cannot be used twice.
Implement two_sum(nums, target).
nums, a list of integers, and target, an integer.target.def two_sum(nums, target):