Count the pairs that fill a block
Resting child orders have sizes (some can be negative, representing sells). You want to know how many pairs of them combine to exactly the block size.
sizes = [1, 5, 7, -1, 5], target = 6
-> 3 # (1,5), (1,5) using the other 5, and (7,-1)
Return the number of unordered index pairs with and sizes[i] + sizes[j] == target. Aim for .
Show a hint
For each new element, how many earlier elements are exactly the complement it needs? A running count of values answers that in .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.