Count Even-Product Triplets
Given an integer array `nums`, return the number of index triplets `(i, j, k)` where `0 <= i < j < k < len(nums)` and the product `nums[i] * nums[j] * nums[k]` is even.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early September, 2026
Given an integer array `nums`, return the number of triplets `(i, j, k)` such that: * `0 <= i < j < k < len(nums)` * `nums[i] * nums[j] * nums[k]` is even. A product is even if at least one of the three selected values is even. ### Example 1 ```text Input: nums = [1, 2, 3, 4] Output: 4 ``` Explanation: The four possible triplets are: ```text [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] ``` ### Example 2 ```text Input: nums = [1, 3, 5, 2] Output: 3 ``` Return the total number of valid triplets.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.