Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can we use the maximum length at the previous position to help us find the answer for the current position?
Can we use binary search to find the maximum consecutive same answer at every position?