Two Sum Is Not About Numbers #1

Open
opened 2026-03-28 12:16:50 -04:00 by deeaitch · 2 comments
Owner

Title: Two Sum Is Not About Numbers

Description:
You are given a list of records. Each record contains:

  • an identifier
  • a value
  • optional metadata

Your task is to find whether there exists a pair of records whose values sum to a given target.

Return the identifiers of any such pair.
If no such pair exists, return an empty result.

Notes:

  • Each record may be used at most once.
  • There is at most one valid answer unless stated otherwise.
  • Input order should not be modified unless explicitly allowed.

Function signature example:
findPair(records, target) -> pair of identifiers or empty result

Example 1:
Input:
records = [
{ id: "A", value: 2 },
{ id: "B", value: 7 },
{ id: "C", value: 11 },
{ id: "D", value: 15 }
]
target = 9

Output:
["A", "B"]

Explanation:
2 + 7 = 9

Example 2:
Input:
records = [
{ id: "X", value: 3 },
{ id: "Y", value: 2 },
{ id: "Z", value: 4 }
]
target = 6

Output:
["Y", "Z"]

Example 3:
Input:
records = [
{ id: "K", value: 3 },
{ id: "L", value: 3 }
]
target = 6

Output:
["K", "L"]

Constraints:

  • 2 <= number of records <= 100000
  • -10^9 <= value <= 10^9
  • -10^9 <= target <= 10^9

Follow-up:
Can you solve it in better than O(n^2) time?

Title: Two Sum Is Not About Numbers Description: You are given a list of records. Each record contains: - an identifier - a value - optional metadata Your task is to find whether there exists a pair of records whose values sum to a given target. Return the identifiers of any such pair. If no such pair exists, return an empty result. Notes: - Each record may be used at most once. - There is at most one valid answer unless stated otherwise. - Input order should not be modified unless explicitly allowed. Function signature example: findPair(records, target) -> pair of identifiers or empty result Example 1: Input: records = [ { id: "A", value: 2 }, { id: "B", value: 7 }, { id: "C", value: 11 }, { id: "D", value: 15 } ] target = 9 Output: ["A", "B"] Explanation: 2 + 7 = 9 Example 2: Input: records = [ { id: "X", value: 3 }, { id: "Y", value: 2 }, { id: "Z", value: 4 } ] target = 6 Output: ["Y", "Z"] Example 3: Input: records = [ { id: "K", value: 3 }, { id: "L", value: 3 } ] target = 6 Output: ["K", "L"] Constraints: - 2 <= number of records <= 100000 - -10^9 <= value <= 10^9 - -10^9 <= target <= 10^9 Follow-up: Can you solve it in better than O(n^2) time?
deeaitch added this to the Beyond Interviews Workflow project 2026-03-28 12:16:50 -04:00
deeaitch changed title from 03 — Two Sum Is Not About Numbers to 03 Two Sum Is Not About Numbers 2026-03-28 12:17:51 -04:00
deeaitch changed title from 03 Two Sum Is Not About Numbers to Two Sum Is Not About Numbers 2026-03-28 12:18:04 -04:00
deeaitch moved this to Working in Beyond Interviews Workflow on 2026-03-28 16:05:40 -04:00
deeaitch self-assigned this 2026-03-28 16:18:26 -04:00
Author
Owner

Another variant of this task:

Given an array of records and an integer target, return the identifiers of the two records such that their values add up to target.

You may assume that each input has at most one solution, and you may not use the same record twice.

You can return the answer in any order.

Another variant of this task: Given an array of records and an integer target, return the identifiers of the two records such that their values add up to target. You may assume that each input has at most one solution, and you may not use the same record twice. You can return the answer in any order.
Author
Owner

Internal note:
This task is intentionally framed as a classic pair-sum problem, but the goal of the analysis is to show that in real engineering the difficulty is usually not the arithmetic itself, but data interpretation, context, constraints, and system behavior.

Internal note: This task is intentionally framed as a classic pair-sum problem, but the goal of the analysis is to show that in real engineering the difficulty is usually not the arithmetic itself, but data interpretation, context, constraints, and system behavior.
deeaitch referenced this issue from a commit 2026-04-16 20:37:29 -04:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: library/beyond-interviews#1