Longest stretch with equal wins and losses
Given a binary array (say 1 for a winning day and 0 for a losing day), return the length of the longest contiguous stretch with an equal number of wins and losses.
days = [1, 0, 1, 1, 0, 0]
-> 6 # three wins, three losses across the whole array
Target time.
Show a hint
Recode each loss as -1. Then "equal wins and losses" becomes a statement about the sum of the stretch. What sum?
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.