Your question is Efficient String and 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.
An Amazon Robotics fulfillment station receives item weights as decimal strings. Given an array of weight strings and an integer target weight, return the indices of two distinct entries whose numeric values sum to the target.
Parse each weight string, including an optional leading + or -, without relying on floating-point arithmetic. Return the pair of indices in ascending order. Each valid input contains exactly one solution.
Implement find_target_pair(weights, target).
weights, an array of strings representing integers, and target, an integer.[i, j], where i < j and the parsed values satisfy weights[i] + weights[j] == target.def find_target_pair(weights, target):