There are some red and blue tiles arranged circularly. You are given an array of integers
colorsand a 2D integers arrayqueries.The color of tile
iis represented bycolors[i]:
colors[i] == 0means that tileiis red.colors[i] == 1means that tileiis blue.An alternating group is a contiguous subset of tiles in the circle with alternating colors (each tile in the group except the first and last one has a different color from its adjacent tiles in the group).
You have to process queries of two types:
queries[i] = [1, sizei], determine the count of alternating groups with sizesizei.queries[i] = [2, indexi, colori], changecolors[indexi]tocolori.Return an array
answercontaining the results of the queries of the first type in order.Note that since
colorsrepresents a circle, the first and the last tiles are considered to be next to each other.