There is a circle of red and blue tiles represented by an integer array colors and an integer k. The color of tile i is denoted by colors[i], where colors[i] is equal to
An alternating group is defined as a sequence of k contiguous tiles in the circle such that every adjacent pair of tiles in the sequence has alternating colors, meaning every tile has a different color from its adjacent neighbors within the sequence.
Return the total number of alternating groups of length k.
Note: Because
colorsrepresents a circle, the first tile and the last tile are adjacent.
Constraints:
colors.length
colors[i]
k colors.length
There is a circle of red and blue tiles represented by an integer array colors and an integer k. The color of tile i is denoted by colors[i], where colors[i] is equal to
An alternating group is defined as a sequence of k contiguous tiles in the circle such that every adjacent pair of tiles in the sequence has alternating colors, meaning every tile has a different color from its adjacent neighbors within the sequence.
Return the total number of alternating groups of length k.
Note: Because
colorsrepresents a circle, the first tile and the last tile are adjacent.
Constraints:
colors.length
colors[i]
k colors.length