https://leetcode.com/problems/three-consecutive-odds
1550. Three Consecutive Odds
給定一個array
假設此數列有連續三個奇數 回傳True
反之回傳False
思路:
記數
Python Code:
class Solution:
def threeConsecutiveOdds(self, arr: List[int]) -> bool:
count = 0
for num in arr:
if num % 2 == 1:
count += 1
else:
count = 0
if count == 3:
return True
return False
我是ez守門員