It's because we're comparing s[i] to s[i-1], not s[i] - 1. At i = 0, s[i-1] would be undefined, so we can't find a match until i = 1.
Thinking about it a different way, any matching substring has to be of even length (since it has an equal amount of 0's and 1's), so the first possible matching substring is when i = 1.
It's because we're comparing s[i] to s[i-1], not s[i] - 1. At i = 0, s[i-1] would be undefined, so we can't find a match until i = 1.
Thinking about it a different way, any matching substring has to be of even length (since it has an equal amount of 0's and 1's), so the first possible matching substring is when i = 1.
It just clicked. Thanks alot!
You're welcome!