Your question is Two-Sum Variant. 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.
An Instacart pricing tool receives a list of integer item values and a target total. Return the indices of two distinct values whose sum equals the target.
You may assume that every valid input contains exactly one solution. Return the indices in increasing order, and do not use the same list element twice. If the list contains duplicate values, each occurrence may be used separately.
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.def two_sum(nums, target):