PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Find two numbers summing to target without hashmap

Last updated: Mar 29, 2026

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.

Related Interview 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)
Meta logo
Meta
Jan 22, 2026, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
4
0
Loading...

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]

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Machine Learning Engineer•Meta Machine Learning Engineer•Meta Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.