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守门员