# Problem Description:

https://leetcode.com/problems/4sum/

# Analysis:

This is another N-Sum problem. We may start by thinking “is the HashMap approach in 2Sum valid here”? The answer is yes if we use two loops to convert this problem into 2sum and use the hashmap approach solving it. Be aware that we need to sort the array to avoid duplication. In fact, this is no time complexity benefit in this case. The sorting takes O(N*log(N)), and the two loops take O(N^2 * N), so the entire time complexity takes O(N^3 + N * log(N)) which is O(N^3).

This is the hash map solution.