FastPrepCount Circular Alternating Binary Windows
Problems/Count Circular Alternating Binary Windows

Count Circular Alternating Binary Windows

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes a circular binary array, a requested window length, strict alternation, and the example [1,0,1,1,0]. We supplied limits and a function signature.

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) → int

Examples

Example 1

bits = [1,0,1,1,0]windowLength = 3return = 3

Starts 0, 3, and 4 produce alternating length-three windows.

Example 2

bits = [0,1,0,1]windowLength = 4return = 4

Every rotation of the circular array alternates for four values.

Constraints

  • 1 <= bits.length <= 100000
  • bits[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

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int countCircularAlternatingWindows(int[] bits, int windowLength) {
        // Write your code here.
    }

}
Checking account…