1550. Three Consecutive Odds ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public: bool threeConsecutiveOdds(vector<int>& arr) { int count = 0; for (const int a : arr) { count = a % 2 == 1 ? count + 1 : 0; if (count == 3) return true; } return false; } }; 1 2 3 4 5 6 7 8 9 10 11class Solution { public boolean threeConsecutiveOdds(int[] arr) { int count = 0; for (final int a : arr) { count = a % 2 == 1 ? count + 1 : 0; if (count == 3) return true; } return false; } } 1 2 3 4 5 6 7 8class Solution: def threeConsecutiveOdds(self, arr: List[int]) -> bool: count = 0 for a in arr: count = count + 1 if a % 2 == 1 else 0 if count == 3: return True return False