A finance dashboard has four panels of adjustments, a, b, c, and d. Picking one adjustment from each panel balances the books if the four add up to 0.
Write zeroBalanceCount(a, b, c, d) that returns how many index tuples (i, j, x, y) have a[i] + b[j] + c[x] + d[y] === 0.
Input: a = [1,-1], b = [0,2], c = [-2,1], d = [1,0] Output: 3
For example 1 + 0 + (-2) + 1 = 0. Three tuples work in total.
Input: a = [0], b = [0], c = [0], d = [0] Output: 1
The only tuple adds up to 0.
0 <= a.length, b.length, c.length, d.length <= 200-2^28 <= values <= 2^28Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #31 Four Panel Zero Balance. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.