In computational complexity theory, the 3SUM problem asks if a given set of n real numbers contains three elements that sum to zero. A generalized version, k-SUM, asks the same question on k elements, rather than simply 3. 3SUM can be easily solved in O(n2) time, and matching Ω(n⌈k/2⌉) lower bounds are known in some specialized models of computation (Erickson 1999). It was conjectured that any deterministic algorithm for the 3SUM requires Ω(n2) time. In 2014, the original 3SUM conjecture was refuted by Allan Grønlund and Seth Pettie who gave a deterministic algorithm that solves 3SUM in O(n2/(logn/loglogn)2/3) time. Additionally, Grønlund and Pettie showed that the 4-linear decision tree complexity of 3SUM is O(n3/2logn). These bounds were subsequently improved. In 2020 (improved on in 2026) the best known algorithm for 3SUM runs in O(n2(loglogn)O(1)/log2n) time. Kane, Lovett, and Moran showed that the 6-linear decision tree complexity of 3SUM is O(nlog2n). The latter bound is tight (up to a logarithmic factor). It was conjectured that 3SUM is unsolvable in O(n2−Ω(1)) expected time, refuted in 2026. When the elements are integers in the range [−N,…,N], 3SUM can be solved in O(n+NlogN) time by representing the input set S as a bit vector, computing the set S+S of all pairwise sums as a discrete convolution using the fast Fourier transform, and finally comparing this set to S. In an October 2026 preprint, Josh Alman and Virginia Vassilevska Williams reported a deterministic algorithm solving 3SUM on polynomially bounded integers in O(n1.9992) time in the word RAM model, and an algorithm solving 3SUM on real numbers in O(n1.998) expected time in the real RAM model. The authors state that these results refute the integer and real-valued versions of the 3SUM conjecture (and refute other conjectures). The paper credits an internal research version of Claude with discovering the core algorithm (it also verified the paper’s main results using the Lean 4 proof assistant with the Mathlib library). Alman and Vassilevska Williams state that Anthropic shared a description of the algorithm with them, and compensated them for extending and writing up the results. The new result spurred more research. Days later on 12 October Ruhollah Majdoddin published a preprint with better bounds for 3SUM (and many other problems, such as related 3XOR) improving "both steps of their algorithm and obtain deterministic algorithms for 3SUM in n1.9945+o(1) time. .. also improve on the preprint's proof sketch for 3XOR and solve it deterministically in O(n1.99451) .. [the] paper was written with Anthropic’s Claude models, Claude Opus 5.5 and Claude Fable 5.1, through Claude Code, in October 2026. Under the author’s direction .. The Lean formalisation described in Section 22.2 was written in the same way. The author takes full responsibility for the content."
Quadratic algorithm Suppose the input array is S[0..n−1]. In integer (word RAM) models of computing, 3SUM can be solved in O(n2) time on average by inserting each number S[i] into a hash table, and then, for each index i and j, checking whether the hash table contains the integer −(S[i]+S[j]). It is also possible to solve the problem in the same time in a comparison-based model of computing or real RAM, for which hashing is not allowed. The algorithm below first sorts the input array and then tests all possible pairs in a careful order that avoids the slowdown of a binary search per pair, achieving worst-case O(n2) time, as follows.
sort(S); for i = 0 to n - 2 do a = S[i]; start = i + 1; end = n - 1; while (start < end) do b = S[start] c = S[end]; if (a + b + c == 0) then output a, b, c; // Continue search for all triplet combinations summing to zero. // We need to update both end and start together since the array values are distinct. start = start + 1; end = end - 1; else if (a + b + c > 0) then end = end - 1; else start = start + 1; end end
The following example shows this algorithm's execution on a small sorted array. Current values of a are shown in red, values of b and c are shown in magenta.
-25 -10 -7 -3 2 4 8 10 (a+b+c==-25) -25 -10 -7 -3 2 4 8 10 (a+b+c==-22) . . . -25 -10 -7 -3 2 4 8 10 (a+b+c==-7) -25 -10 -7 -3 2 4 8 10 (a+b+c==-7) -25 -10 -7 -3 2 4 8 10 (a+b+c==-3) -25 -10 -7 -3 2 4 8 10 (a+b+c==2) -25 -10 -7 -3 2 4 8 10 (a+b+c==0)
The correctness of the algorithm can be seen as follows. Suppose we have a solution a + b + c = 0. Since the pointers only move in one direction, we can run the algorithm until the leftmost pointer points to a. Run the algorithm until either one of the remaining pointers points to b or c, whichever occurs first. Then the algorithm will run until the last pointer points to the remaining term, giving the affirmative solution.
Variants
Non-zero sum Instead of looking for numbers whose sum is 0, it is possible to look for numbers whose sum is any constant C. The simplest way would be to modify the original algorithm to search the hash table for the integer (C−(S[i]+S[j])). Another method:
Subtract C/3 from all elements of the input array. In the modified array, find 3 elements whose sum is 0. For example, if A=[1,2,3,4] and if you are asked to find 3SUM for C=4, then subtract 4/3 from all the elements of A, and solve it in the usual 3sum way, i.e., (a−C/3)+(b−C/3)+(c−C/3)=0.
Three different arrays Instead of searching for the 3 numbers in a single array, we can search for them in 3 different arrays. I.e., given three arrays X, Y and Z, find three numbers a∈X, b∈Y, c∈Z, such that a+b+c=0. Call the 1-array variant 3SUM×1 and the 3-array variant 3SUM×3. Given a solver for 3SUM×1, the 3SUM×3 problem can be solved in the following way (assuming all elements are integers):
For every element in X, Y and Z, set: X[i]←X[i]∗10+1, Y[i]←Y[i]∗10+2, Z[i]←Z[i]∗10−3. Let S be a concatenation of the arrays X, Y and Z. Use the 3SUM×1 oracle to find three elements a′∈S, b′∈S, c′∈S such that a′+b′+c′=0. Return a←(a′−1)/10, b←(b′−2)/10, c←(c′+3)/10. By the way we transformed the arrays, it is guaranteed that a∈X, b∈Y, c∈Z.
Convolution sum Instead of looking for arbitrary elements of the array such that:
S[k]=S[i]+S[j] the convolution 3sum problem (Conv3SUM) looks for elements in specific locations:
S[i+j]=S[i]+S[j]
… excerpt ends here. Continue reading the full article.