Re: [閒聊] 每日leetcode

作者: sustainer123 (caster)   2024-07-01 10:07:10
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守門員
作者: oin1104 (是oin的說)   2024-07-01 10:18:00
大清早就在卷 我哭了
作者: sustainer123 (caster)   2024-07-01 10:19:00
早上刷題比較方便安排之後的時間
作者: DJYOMIYAHINA (通通打死)   2024-07-01 10:20:00
別捲了

Links booklink

Contact Us: admin [ a t ] ucptt.com