# LeetCode 1550. Three Consecutive Odds ###### tags: `python`,`LeetCode` >這邊使用Python解題 ## 題目: Given an integer array `arr`, return `true` if there are three consecutive odd numbers in the array. Otherwise, return `false`. 總而言之要找出`arr`中是否存在連續的三個奇數,如果為真回傳`True`,否則回傳`False`。 ## 範例 ### 範例 1: ``` Input: arr = [2,6,4,1] Output: false Explanation: There are no three consecutive odds. ``` ### 範例 2: ``` Input: arr = [1,2,34,3,4,5,7,23,12] Output: true Explanation: [5,7,23] are three consecutive odds. ``` ## 條件限制 * `1 <= arr.length <= 1000` * `1 <= arr[i] <= 1000` ## 我的解題思路: 我好喜歡這種小趴菜題目,直接貼Code。 ## 程式碼: ```python def threeConsecutiveOdds(self, arr: List[int]) -> bool: res=0 for item in arr: if item % 2 != 0: res+=1 else: res = 0 if res == 3: return True return False ``` ###### Topic: `Array`