Tap here to switch tabs
Problem
Submissions

Problem: Alternating Groups I

med
30 min
Try to solve the Alternating Groups I problem.

Statement

You are given a circular array of binary integers colors. An alternating group is defined as a contiguous subarray of 33 elements where adjacent elements alternate in value (that is, the middle element differs from both its left and right neighbors).

Because colors is circular, the first and last elements are considered adjacent.

Return the total number of alternating groups of size 33.

Constraints:

  • 3≤3 \leq colors.length ≤100\leq 100

  • 0≤0 \leq colors[i] ≤1\leq 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Alternating Groups I

med
30 min
Try to solve the Alternating Groups I problem.

Statement

You are given a circular array of binary integers colors. An alternating group is defined as a contiguous subarray of 33 elements where adjacent elements alternate in value (that is, the middle element differs from both its left and right neighbors).

Because colors is circular, the first and last elements are considered adjacent.

Return the total number of alternating groups of size 33.

Constraints:

  • 3≤3 \leq colors.length ≤100\leq 100

  • 0≤0 \leq colors[i] ≤1\leq 1