Problem 3101 · Medium

Count Alternating Subarrays

Count alternating subarrays by keeping the length of the alternating run that ends at each index.

Open the interactive visualisation