aboutsummaryrefslogtreecommitdiff
path: root/three_consecutive_odds.py
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-05-10 21:14:53 -0600
committerJack Sangdahl <[email protected]>2025-05-10 21:14:53 -0600
commiteee47c29b5dd2a152a3c898525b8871503625a3e (patch)
treeaedbeaad2de66b8250858038bed90ad1ecf00d4c /three_consecutive_odds.py
parent42c1b2150db0dfed4e106379f8ad6dc966bb3c2e (diff)
downloadleetcode-eee47c29b5dd2a152a3c898525b8871503625a3e.tar.gz
leetcode-eee47c29b5dd2a152a3c898525b8871503625a3e.zip
1550. three consecutive odds
Diffstat (limited to 'three_consecutive_odds.py')
-rw-r--r--three_consecutive_odds.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/three_consecutive_odds.py b/three_consecutive_odds.py
index 62fafe3..7abb6bb 100644
--- a/three_consecutive_odds.py
+++ b/three_consecutive_odds.py
@@ -12,7 +12,15 @@ class Solution(object):
:type arr: List[int]
:rtype: bool
"""
- return "111" in "".join([str(i % 2) for i in arr])
+ cnt = 0
+ for i in arr:
+ if i % 2 != 0:
+ cnt += 1
+ if cnt == 3:
+ return True
+ else:
+ cnt = 0
+ return False
if __name__ == "__main__":