Quick Overview

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

Find two numbers that sum to a target

Company: Agoda

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

### 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`

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

Return two distinct 0-based indices whose values sum to target, or [] if none exists.

Examples

Input: ([2, 7, 11, 15], 9)

Expected Output: [0, 1]

Explanation: Classic.

Input: ([3, 3], 6)

Expected Output: [0, 1]

Explanation: Duplicate values.

Loading coding console...