JavaScript sliding window
Move right pointer until odd number reach k, then count even number towards right until reach next odd number or the end, count even number towards left untill 
Move right pointer until odd number reach k, then count even number towards right until reach next odd number or the end, count even number towards left untill left pointer is sitting on an odd number, the product of left and right is the answer for this window, at last move left pointer and reduce odd number for 1 for next window.\n\n```\nvar numberOfSubarrays = function(nums, k) {\n    let count = 0;\n    let odd = 0;\n    let l = 0, r = -1;\n    while(r < nums.length-1) {\n        r++;\n        if (nums[r]%2 !== 0) odd++;\n        if (odd === k) {\n            let right = 1;\n            let left = 1;\n            // move r if next element is even\n            while(r < nums.length-1 && nums[r+1]%2 === 0) {\n                r++;\n                right++;\n            }\n            // move l if current element for l is even\n            while(l < r && nums[l]%2 === 0) {\n                l++;\n                left++;\n            }\n            count += left*right;\n            l++;\n            odd--;\n        }\n    }\n    return count;\n};\n```
[]