Count Circular Alternating Binary Windows
Updated
Problem statement
You are given a nonempty binary array bits, treated as circular, and an integer windowLength.
For every start index in the original array, inspect the next windowLength values around the circle. Count how many such windows strictly alternate between 0 and 1.
Function
countCircularAlternatingWindows(bits: int[], windowLength: int) → intExamples
Example 1
bits = [1,0,1,1,0]windowLength = 3return = 3Starts 0, 3, and 4 produce alternating length-three windows.
Example 2
bits = [0,1,0,1]windowLength = 4return = 4Every rotation of the circular array alternates for four values.
Constraints
1 <= bits.length <= 100000bits[i]is 0 or 1.1 <= windowLength <= bits.length
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Earn the Most 🐝Capital One · OACapital One interview questions
- Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions
- Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
- Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
- Reschedule Meetings for Maximum Free TimeFivetran · OAFivetran interview questions
- Count Subarrays with at Least K Equal-Fruit PairsTikTok · OATikTok interview questions
- Consistent LogsRippling · OARippling interview questions
- Minimum Team Size From Every StartCognizant · OA
- Minimum of Fixed-Window MaximaJuspay · OA
- Sliding-Window Means with IEEE Special ValuesHeadlands Technologies · OAHeadlands Technologies interview questions