Count subarrays with odd zero count
SIG (Susquehanna)Software Engineer · Online AssessmentLast updated
This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Count subarrays with odd zero count states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Given an integer array nums, return how many contiguous subarrays contain an odd number of zeros. Provide an O(n) solution (e.g., using prefix parity counts of zero occurrences) and state its time and space complexity. Example: nums = [0, 0, 1, 0, 1] -> 4.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.