PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Find two numbers that sum to target

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competency in basic algorithmic problem-solving within the Coding & Algorithms domain, focusing on array manipulation, pair-sum reasoning, and analysis of time-space trade-offs.

  • medium
  • Amazon
  • Coding & Algorithms
  • Machine Learning Engineer

Find two numbers that sum to target

Company: Amazon

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an integer array `nums` of length `n` and an integer `target`, return the indices `(i, j)` (0-based) of two **distinct** elements such that `nums[i] + nums[j] == target`. Requirements: - Return any one valid pair of indices. - You may assume **exactly one** valid pair exists. - The same element cannot be used twice. **Input:** `nums: int[]`, `target: int` **Output:** two indices `i, j` **Constraints (typical):** - `2 <= n <= 1e5` - `-1e9 <= nums[k] <= 1e9` - `-1e9 <= target <= 1e9`

Quick Answer: This question evaluates a candidate's competency in basic algorithmic problem-solving within the Coding & Algorithms domain, focusing on array manipulation, pair-sum reasoning, and analysis of time-space trade-offs.

Related Interview Questions

  • Count Connected Components in an Undirected Graph - Amazon (medium)
  • Find Unique Target-Sum Pairs - Amazon (easy)
  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
Amazon logo
Amazon
Nov 20, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
1
0

Given an integer array nums of length n and an integer target, return the indices (i, j) (0-based) of two distinct elements such that nums[i] + nums[j] == target.

Requirements:

  • Return any one valid pair of indices.
  • You may assume exactly one valid pair exists.
  • The same element cannot be used twice.

Input: nums: int[], target: int

Output: two indices i, j

Constraints (typical):

  • 2 <= n <= 1e5
  • -1e9 <= nums[k] <= 1e9
  • -1e9 <= target <= 1e9

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Machine Learning Engineer•Amazon Machine Learning Engineer•Amazon Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.