Hey, first timer here, wondering if anyone would like to throw clues at me or put our heads together to try to figure this one out without looking at solutions.

I realized quickly (after figuring out brute force) that this was some sort of dp problem. My solution that I came up with afaik works however was too slow, I timed out after the 22nd test. My dp is super rusty.

I'm going to try to explain my solution. The value I'm hashing is "balance" which is 0 if there are equal number of 0s and 1s and incrementally negative or positive if there is 1, 2, 3, etc. more 1s than 0s or vice versa. My solution is essentially looping through and creating new "balance" values by looking into my hash. Each outer loop I increase my subarray length by 1. I'm stuck here, I feel like I'm missing a key part in structuring my loops such that the solution is much faster...