Easy

Find a Pair Matching a Target DSA Interview

Given a sequence of integers and a target value, return the positions of two distinct entries whose values add to the target.

1. Problem Statement

You are given a list of integers and a target. Return the indices of two different entries whose values sum to the target.

2. Live Coding Format

Choose Python, JavaScript, Java, or C++, then solve while explaining your reasoning to the live interviewer.

Validation uses handwritten tests only. The MVP does not compile or run code, and it does not provide AI algorithm completion.

3. Key Focus Areas

  • 1
    Problem clarification and contract
  • 2
    Approach exploration and optimality
  • 3
    Think-aloud communication and pacing
  • 4
    Implementation correctness
  • 5
    Code quality and language fluency
  • 6
    Handwritten tests and dry run
  • 7
    Debugging and self-correction
  • 8
    Complexity analysis
  • 9
    Follow-up performance

4. What Strong Candidates Should Demonstrate

  • Clarify input, output, uniqueness, and no-solution behavior before coding.
  • Explain a baseline approach, identify its bottleneck, and select an optimal conventional solution.
  • Think aloud while implementing readable, correct code.
  • Validate with explicit expected outputs and a top-to-bottom handwritten dry run.
  • Analyze time and space complexity and pace the easy core problem to leave room for a coding follow-up.

Evaluation Guide

This is an evaluation framework, not a single model answer. Strong designs may make different choices when their assumptions and trade-offs are explicit.

Problem clarification and contract

10%

Senior signals

  • Clarifies whether one solution is guaranteed, whether duplicates and negative values are allowed, and what to return when no pair exists.
  • Confirms that the two indices must be distinct and asks about input size or constraints when relevant.

Staff-level signals

  • Makes a concise contract and identifies ambiguity that could affect an API or production caller.

Common red flags

  • ×Codes immediately while relying on unstated assumptions.

Approach exploration and optimality

20%

Senior signals

  • Explains a direct quadratic approach, identifies repeated lookup work, and improves to a conventional lookup-based single pass.
  • If multiple valid methods are discussed, compares them and selects the optimal conventional solution before coding.

Staff-level signals

  • Compares behavior under streaming input, memory limits, or multiple repeated queries.

Common red flags

  • ×Starts implementation without explaining an approach even after one interviewer prompt.
  • ×Chooses a needlessly exotic contest technique over a clear conventional optimal solution.

Think-aloud communication and pacing

10%

Senior signals

  • Explains the plan before coding and narrates important invariants, branches, and corrections while implementing.
  • Uses comments, examples, or handwritten cases to make reasoning visible.
  • Completes the easy core problem efficiently enough to leave meaningful time for validation and a follow-up.

Common red flags

  • ×Writes substantial code silently and cannot explain what the code is doing.
  • ×Spends most of the interview on the easy core problem and leaves insufficient time for a follow-up.

Implementation correctness

25%

Senior signals

  • Implements a correct single-pass lookup solution that checks for the complement before storing the current index.
  • Handles duplicates, negative values, distinct indices, and the stated no-solution contract.
  • Provides a convincing invariant or step-by-step correctness argument.

Common red flags

  • ×Returns values instead of indices or permits using one entry twice.
  • ×Final code contains a material correctness bug that the candidate does not identify.

Code quality and language fluency

15%

Senior signals

  • Produces readable, language-appropriate code with clear names, controlled branching, and a defined no-solution path.

Staff-level signals

  • Mentions numeric or language-specific safety only when it is relevant.

Common red flags

  • ×Contains index/value confusion, avoidable mutation, or syntax-level incoherence that prevents credible reasoning.

Handwritten validation, dry run, and debugging

10%

Senior signals

  • Provides explicit inputs and expected outputs before tracing the code from top to bottom.
  • Covers ordinary, duplicate, negative, no-solution, and minimal-size cases.
  • Finds and fixes an error independently, then re-validates the affected path.

Common red flags

  • ×Claims the code works without a representative trace.

Complexity analysis and follow-up

10%

Senior signals

  • States expected linear time and linear auxiliary space and compares them with direct nested search.
  • When a follow-up is asked with sufficient time, adapts the approach, implements it coherently, and analyzes its complexity.

Staff-level signals

  • Discusses deterministic alternatives, sorting costs, repeated queries, or streaming constraints without losing focus.

Common red flags

  • ×Cannot state the complexity of the implemented solution.
  • ×Fails a reasonable follow-up after solving an easy first problem, despite having at least five minutes and receiving bounded clarification.
  • ×Makes no meaningful progress on the follow-up after consuming most of the interview on the easy core problem.

Trade-offs to articulate

  • Nested search uses constant extra space but quadratic time.
  • A lookup table improves expected time while using additional memory.
  • Sorting can reduce lookup storage but complicates preservation of original indices.

Practice follow-up questions

  1. 1.Coding follow-up: modify the solution to return all unique value pairs whose values sum to the target, without duplicate pairs.
  2. 2.Verbal extension: how would the approach change if many different targets were queried against the same immutable list?
  3. 3.Verbal extension: how would the approach change if the input arrived as a stream?

Want interactive feedback?

Practice this problem in the live coding workspace while the interviewer probes your clarification, algorithm, implementation, complexity, and handwritten tests.

Start Interview

Core Concepts

ArraysHash MapsComplexity AnalysisEdge Cases