[Python] Easy to understand, Sliding window (Left & Right evens), Faster than 100%
\tclass Solution(object):\n\t\tdef numberOfSubarrays(self, nums, k):\n\t\t\t"""\n\t\t\te.g. k = 2\n\t\t\tnums = [2, 2, 1, 2, 1, 2, 2]\n\t\t\tindex=  0  1  2  3 
\tclass Solution(object):\n\t\tdef numberOfSubarrays(self, nums, k):\n\t\t\t"""\n\t\t\te.g. k = 2\n\t\t\tnums = [2, 2, 1, 2, 1, 2, 2]\n\t\t\tindex=  0  1  2  3  4  5  6\n\t\t\t2 even numbers to left of first 1\n\t\t\t2 even numbers to right of last 1\n\t\t\ttotal number of subarrays = pick between 0-2 numbers on left, then, pick between 0-2 numbers on right\n\t\t\ti.e (left+1)  (right+1)\n\t\t\tThen slide window to next set of 2 odd numbers\n\t\t\t"""\n\n\t\t\todds = []\n\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\todds.append(i)                      #\' Find index of all odd numbers \'\n\n\t\t\todds = [-1] + odds + [len(nums)]            #\' Handle edge cases \'\n\t\t\tnice = 0\n\n\t\t\tfor i in range(1, len(odds)-k):\n\t\t\t\tleft = odds[i] - odds[i-1] - 1          #\' Number of \'left\' even numbers \'\n\t\t\t\tright = odds[i+k] - odds[i+k-1] - 1     #\' Number of \'right\' even numbers \'\n\t\t\t\tnice += (left+1)*(right+1)              #\' Total sub-arrays in current window \'\n\n\t\t\treturn nice\n        \n
['Python']