Katkat

Find two numbers that sum to a target

AgodaSoftware Engineer · Technical Screen

Last updated

This question evaluates array manipulation, index-based reasoning, and algorithmic problem-solving skills related to identifying value pairs that meet a numeric target.

Array sum lookup

Given an integer array nums and an integer target, find two distinct indices i and j such that:

  • nums[i] + nums[j] == target
  • i != j

Return the pair of indices (in any order). If no such pair exists, return an empty result.

Clarifications to confirm in interview

  • Are there negative numbers? (Assume yes.)
  • If multiple answers exist, can we return any one? (Assume yes.)
  • What output format is expected (0-based indices, 1-based indices, or the values themselves)? Specify and be consistent.

Constraints (typical)

  • 1 <= nums.length <= 1e5
  • -1e9 <= nums[i], target <= 1e9