18. 4Sum
# Medium
Similar to #15 3Sum problem.
Two index(fixed) pointers(i: 0 to len(nums)-3; j: i+1 to len(nums)-2
) and two flexible pointers(z: j+1; k: len(nums)-1
).
In order to avoid duplication, check duplicated number immediately after the two for
loops.
Time complexity = , space complexity = .
It can be extended to kSum problem. Time complexity =
Last updated