All practice tasks

Coding (Algo)

Find a Pair With the Target Total

Hash map · Easy

A reconciliation check needs two distinct batch entries whose amounts add to a requested total. Entries may have equal amounts but the same entry cannot be used twice. The check only needs existence, not indexes or a list of all matching pairs.

Return whether two different indexes in the supplied amount array have values that sum exactly to the target.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ nums: integer[], target: integer }

Fields

  • nums is an unsorted array of signed integer amounts; target is the required sum.

Output

Return value

  • Return a boolean. Duplicate amounts are allowed, but two distinct occurrences are required.
  • Empty and single-entry batches return false.

Constraints

  • 0 <= nums.length <= 100000; each value is an integer between -1000000000 and 1000000000.
  • -2000000000 <= target <= 2000000000.

Examples

Example 1

{
  "nums": [
    4
  ],
  "target": 8
}

Returns

false

Example 2

{
  "nums": [
    4,
    4
  ],
  "target": 8
}

Returns

true

Required complexity

O(n) expected time and O(n) auxiliary space

What this task practices

Find a Pair With the Target Total is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.