#3208
Alternating Groups II
specialist · 720 · lc medium +30 · 59.9% accepted · 763 likes · top 58%
Description
A circle of tiles is colored red or blue via integer array colors (0 = red, 1 = blue). Given integer k, an alternating group is k consecutive circular tiles where every interior tile differs from both its neighbors in the group.
Return the number of alternating groups. The first and last tiles are adjacent.
Code
1
2
3