streaming-counter-reset-pattern

Status: IN

The "streaming counter with reset" idiom — increment on match, reset to 0 on mismatch — is used to detect k consecutive elements satisfying a predicate in O(n) time and O(1) space; `threeConsecutiveOdds` uses it with k=3.

Source: entries/2026/06/06/three-consecutive-odds-solution.md

JSON