67. 4Sum II

Count the number of tuples where the sum of elements from four arrays equals zero.
Example 1
Input: nums1 = [1,-1], nums2 = [1,-1], nums3 = [1,-1], nums4 = [1,-1]
Output: 6
Explanation: A sum of zero comes from all combinations where the counts of +1 and -1 are balanced.
Example 2
Input: nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2]
Output: 2
Explanation: There are two tuples with a total sum of 0.
Example 3
Input: nums1 = [0], nums2 = [0], nums3 = [0], nums4 = [0]
Output: 1
Explanation: The only tuple (0,0,0,0) gives a sum of 0.
arrayshash tablemedium
JavaScript
Loading...
Line 1, Char 1