Practice Alternating Groups III
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The circular array colors uses 0 for red and 1 for blue. Process [1, size] by counting circular contiguous groups of that length whose neighboring tiles within the group alternate colors. Process [2, index, color] by changing that tile’s color. Groups may wrap around the array boundary. Return the results of type-1 queries in order.
Source: Alternating Groups III on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
colors = [0,1,1,0,1], queries = [[2,1,0],[1,4]]
[2]
# Example 2
colors = [0,0,1,0,1,1], queries = [[1,3],[2,3,0],[1,5]]
[2,0]
Constraints
Related LeetCode Problems
Practice more problems similar to Alternating Groups III.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.