A large fintech processes tens of millions of card transactions per day. During chargeback investigations, analysts often look for pairs of transactions whose amounts sum to a suspicious threshold (e.g., two split purchases that together hit a reporting limit). You’re building a backend utility that must find such a pair quickly to keep investigation tooling responsive.
Given an integer array amounts (transaction amounts in cents) and an integer target (also in cents), return the indices of the two distinct elements such that:
amounts[i] + amounts[j] == targeti != jamounts: List[int], target: intList[int] of length 2: [i, j]j. If still tied, choose the one with the smallest first index i.[].amounts = [200, 700, 1100, 1500], target = 900[0, 1]amounts[0] + amounts[1] = 200 + 700 = 900.amounts = [300, 300, 400, 500], target = 600[0, 1]300 entries form the target. The tie-breaking rule prefers the earliest j (which is 1).2 <= amounts.length <= 200_000-10^9 <= amounts[i] <= 10^9-10^9 <= target <= 10^9