# Letcode 454 - 4sum II

Note:

• It looks terrifying but actually it’s way more easier than 4Sum I.
• Use a hash table map to store all different sums of nums1, nums2, and their frequencies. (Store frequencies because each -sum from nums3 and nums4 can combine with the pair whose key is sum in map.)
• Then use another for loop to check all possible sum and check if it’s been stored in map as key -sum. The frequency is how many combination we can get for each sum.

Question:

Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:

• 0 <= i, j, k, l < n
• nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0

Example:

Code: