The TransCompilator

Solved LeetCode program · 902 of 1,000

#1248 · Count Number of Nice Subarrays

Medium Array chunk-19.md

Original English source

The readings is a list of 1, 1, 2, 1, and 1. The wanted is 3. The seen is a list of 6 zeros. Set item 0 of seen to 1. The odds is 0. The ways is 0.
For each value in readings.
If value modulo 2 is 1, add 1 to odds. If odds is at least wanted, The prior is item (odds minus wanted) of seen, Set ways to ways plus prior. Increase item odds of seen by 1.

Show ways.

Open in Playground Browse all 1,000 problems

Expected stdout

2