leetpycode/easy/three_consecutive_odds.py

15 lines
362 B
Python

#https://leetcode.com/problems/three-consecutive-odds
from typing import List
class Solution:
def threeConsecutiveOdds(self, arr: List[int]) -> bool:
cnt = 0
for v in arr:
if v % 2 == 0:
cnt = 0
continue
cnt += 1
if cnt >= 3:
break
return cnt >= 3