Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Two-account transfer matching

Python data engineering interview problem. Difficulty: intermediate. Pattern: Hashing. About 15 minutes. Part of the Pro drill bank.

Two ledger lines should pair when their amounts add to a target transfer size. Accounting wants those two indices (or values) if they exist.

Find two amounts that add to the target transfer (two-sum on the list).

Requirements

  • Use each position at most once unless tests allow it.
  • Return the pair or indices the tests specify.

Constraints

  • amounts: list of numbers.
  • No pair: return the documented sentinel.
  • Duplicates of the same amount may or may not pair with themselves.

Examples

Input: complementary_pair([1, -1, 2]) Output: [0, 1] This input follows the stated rules and produces this output.

Topics: lakebench, python, hash-based-problems.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Two-account transfer matching

Interview-style drill: Given a list of transfer amounts, find a pair that sums to exactly zero net movement.

Find two amounts that add to the target transfer (two-sum on the list).