ByteByteGo logo
menuProblems List

Pair Sum - Unsorted

Easy

Given an array of integers, return the indexes of any two numbers that add up to a target. The order of the indexes in the result doesn't matter. If no pair is found, return an empty array.

Example:

Input: nums = [-1, 3, 4, 2], target = 3
Output: [0, 2]

Explanation: nums[0] + nums[2] = -1 + 4 = 3

Constraints:

  • The same index cannot be used twice in the result.

You can practice coding exercises online by logging into bytebytego.com on your laptop.