This problem taught you the consecutive element pattern. You maintain a counter that resets when the pattern breaks and grows when it continues. This appears in many problems where you find longest runs or detect duplicates.
I showed you the early exit optimization. When you find what you're looking for, stop immediately. This saves operations and makes your code faster. You also learned about comparing adjacent elements.
Starting your loop at index 1 and comparing to is common. Watch your loop bounds to avoid accessing elements outside the array.