The four lists a, b, c and d have the same length n. Return how many tuples of positions (i, j, k, l) satisfy a[i] + b[j] + c[k] + d[l] == 0. Different positions count separately even when the values are equal.
The starter code tries every tuple. It is correct but far too slow. Make it fast.
Example 1
Input:
four_sum_count([1, 2], [-2, -1], [-1, 2], [0, 2])
Output:
2
Two tuples work: positions (0, 0, 0, 1) and (1, 1, 0, 0).
Example 2
Input:
four_sum_count([0], [0], [0], [0])
Output:
1
The only tuple adds to 0.
0 <= n <= 400-10**6 <= value <= 10**6n.No results yet
Run your code to check it against the examples, or submit to run every test.