From 265fcfa6b155383d22ee5410b494496b6b30ede6 Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Mon, 1 Jul 2024 21:29:59 +0900 Subject: [PATCH] https://leetcode.com/problems/three-consecutive-odds --- easy/three_consecutive_odds.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 easy/three_consecutive_odds.py diff --git a/easy/three_consecutive_odds.py b/easy/three_consecutive_odds.py new file mode 100644 index 0000000..f2acc86 --- /dev/null +++ b/easy/three_consecutive_odds.py @@ -0,0 +1,15 @@ +#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 +