Algorithm · Amazon · Medium
Given an array of integers nums and an integer target, find a pair of distinct zero-based indices i and j, with i < j, for which $$nums[i] + nums[j] = target$$. Return the pair as [i, j]. If several pairs satisfy the condition, choose the pair with the smallest first index; if there is still a tie, choose the one with the smallest second index. If no such pair exists, return []. Do not assume nums is sorted; its values may repeat and may include zero or negative integers.…
Checking your access…