2Sum, 3Sum, and 4Sum are the same idea at different depths: fix pointers one at a time,
and once only two free slots remain, collapse to the familiar converging two-pointer
scan. Pick any k and watch the recursion stack grow and shrink.
Execution
idle
Press Run to begin.
0 / 0
Speed
Java · running line
level 1level 2level 3level 4leftrightfound
O(n^(k-1)) time · O(k) recursion depth · k−2 nested fixed pointers, then one O(n) two-pointer pass.