Two Sum with Smallest-Indices Tiebreak

Asked at Walmart Labs · Coding Questions · Difficulty: Medium · Last asked Mar 3, 2026

Given an unsorted array and a target sum, return the indices `(i, j)` of any two elements summing to the target. If multiple pairs exist, return the one with the smallest `i`; on ties, the smallest `j`. A verbal follow-up extends the problem to 3-sum with duplicate removal.

Loading the problem…