Algorithm · Google · Medium
Implement twoSumSmallestPair(nums, target). Given an integer array nums and an integer target, find two distinct indices i and j with i < j such that nums[i] + nums[j] == target. Among all such pairs, return the lexicographically smallest one as [i, j]. A pair [a, b] is lexicographically smaller than [c, d] if a < c, or if a == c and b < d. Equivalently, minimize the left index first, then minimize the right index among pairs with that left index. If no pair exists, return…
Checking your access…