Search
⌘K

Leetcode 1248. Count Number of Nice Subarrays

Count the number of contiguous subarrays that contain exactly k odd numbers in an integer array. The core challenge is to do this in linear time by using parity prefix counts (or by counting even-number gaps between odds) to compute how many subarrays end at each position.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.