Your question is Two Numbers With Target Sum. 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 Wizeline Platform data-processing job receives an unsorted array of integer measurements and a target sum. Return the indices of two distinct elements whose values add up to the target.
Use each array element at most once. Return the indices in ascending order. You may assume every valid input contains exactly one solution.
Implement two_sum(nums, target):
nums, a list of integers, and target, an integer.[i, j], where i < j and nums[i] + nums[j] == target.The solution should efficiently handle large arrays. Consider how a hash map can avoid checking every possible pair.
def two_sum(nums, target):