PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates array manipulation, index-tracking, and algorithmic problem-solving skills, with emphasis on time and space complexity trade-offs when locating two elements that sum to a given target under input-size constraints.

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

Find two numbers summing to target without hashmap

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem Given an integer array `nums` (length `n`) and an integer `target`, return the **indices** `(i, j)` such that: - `i != j` - `nums[i] + nums[j] == target` You may assume **exactly one** valid pair exists. ## Constraints - `2 <= n <= 2 * 10^5` - `-10^9 <= nums[k], target <= 10^9` ## Requirements - Do **not** use a hash map / hash set solution. - Aim to use sorting + two pointers. - Output must be indices in the **original** array. ## Input/Output - **Input:** `nums`, `target` - **Output:** a pair of indices `[i, j]` (order does not matter) ## Example - `nums = [2, 7, 11, 15]`, `target = 9` → output could be `[0, 1]`

Quick Answer: This question evaluates array manipulation, index-tracking, and algorithmic problem-solving skills, with emphasis on time and space complexity trade-offs when locating two elements that sum to a given target under input-size constraints.

Use sorting plus two pointers and return original indices for the unique pair; indices are sorted ascending.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

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

Expected Output: [0, 1]

Explanation: Prompt example.

Input: ([3,2,4], 6)

Expected Output: [1, 2]

Explanation: Middle pair.

Input: ([-1,-2,-3,-4,-5], -8)

Expected Output: [2, 4]

Explanation: Negative values.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)