Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 3101. Count Alternating Subarrays
Count the number of contiguous subarrays in a binary array where no two adjacent elements are equal (i.e., the subarray alternates). With n up to 1e5, this is solved by scanning for maximal alternating runs and summing how many subarrays each run contributes (linear time).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.