Leetcode 1293 Solution

This article provides solution to leetcode question 1293 (three-consecutive-odds)

https://leetcode.com/problems/three-consecutive-odds

Solution

class Solution:
    def threeConsecutiveOdds(self, arr: List[int]) -> bool:
        odd_cnt = 0

        for v in arr:
            if v % 2 == 1:
                odd_cnt += 1
            else:
                odd_cnt = 0

            if odd_cnt == 3:
                return True
        return False