3Sum. My solution here is to use a hash table to achieve a O(n2) performance. Basically you can just brute force two number, and check if the last number exists…

4Sum. This problem is similar to the previous 3Sum problem, just add one more layer of fixed numbers. The complexity will be O(n3). Different to the 3Sum problem though, this one…

3Sum Closest. This problem can be solved by search all possible 3-tuple. But this will end up with a O(n3) complexity. A smarter way is to search through one of…