Four-sum problem Created 2026-10-20 Updated 2026-11-05
The four-sum problem asks whether four selected numbers sum to a target , with the selection rules part of the input specification. In the four-list version, choose one value from each of . Store sums and look for , a meet-in-the-middle algorithm. For lists of length , hashing gives expected time and storage; sorting pair sums gives deterministic comparison-based alternatives. In a single-list version requiring four distinct positions, stored pairs must also satisfy the index-disjointness condition. Equal values and equal positions are different restrictions.