diff options
Diffstat (limited to 'three_consecutive_odds.py')
-rw-r--r-- | three_consecutive_odds.py | 10 |
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__": |