Ezvor

2495. Number of Subarrays Having Even Product

MediumArray Preparing judge… LeetCode
ArrayMathDynamic Programming

Hints

Hint 1
The product of elements in a subarray is even if it contains at least one even element.
Hint 2
Iterate from left to right and save the last index of an even number. Let that saved index be “j”.
Hint 3
It can be seen that every subarray starting from earlier than index “j” and ending at the current index has an even product.