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 == 0 ? 0 : count + 1; 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 == 0 ? 0 : count + 1; 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 = 0 if a % 2 == 0 else count + 1 if count == 3: return True return False