Tap here to switch tabs
Problem
Submissions

Problem: Count Alternating Subarrays

med
30 min
Try to solve the Count Alternating Subarrays problem.

Statement

You are given a binary array nums.

A subarray is considered alternating if no two adjacent elements within the subarray have the same value.

Return the total number of alternating subarrays in nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • nums[i] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Alternating Subarrays

med
30 min
Try to solve the Count Alternating Subarrays problem.

Statement

You are given a binary array nums.

A subarray is considered alternating if no two adjacent elements within the subarray have the same value.

Return the total number of alternating subarrays in nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • nums[i] is either 00 or 11.