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 numbers. 3SUM can be easily solved in \(\bigo{n^2}\) time, \({\bigomega{n^{\lceil k/2\rceil }}}\) lower bounds are known in some specialized models of computation (Erickson 1999).
Three sum is a Technical interview question and a variant of the Subset sum problem.
Quadratic solution (\(\bigo{n^2}\))
Bibliography
References
“3SUM.” 2022. Wikipedia, September. https://en.wikipedia.org/w/index.php?title=3SUM&oldid=1111084529.