3101. Count Alternating Subarrays
You are given a binary array nums. We call a subarray alternating if no two adjacent elements in the subarray have the same value. Return the number of alternating subarrays in nums. Example 1: Input: nums = [0,1,1,1] Output: 5 Explanation: The following subarrays are alternating: [0], [1], [1], [1], and [0,1]. Example 2: Input: nums = [1,0,1,0] Output: 10 Explanation: Every subarray
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start