1550. Three Consecutive Odds LeetCode Solution
In this guide, you will get 1550. Three Consecutive Odds LeetCode Solution with the best time and space complexity. The solution to Three Consecutive Odds problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Three Consecutive Odds solution in C++
- Three Consecutive Odds solution in Java
- Three Consecutive Odds solution in Python
- Additional Resources

Problem Statement of Three Consecutive Odds
Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.
Example 1:
Input: arr = [2,6,4,1]
Output: false
Explanation: There are no three consecutive odds.
Example 2:
Input: arr = [1,2,34,3,4,5,7,23,12]
Output: true
Explanation: [5,7,23] are three consecutive odds.
Constraints:
1 <= arr.length <= 1000
1 <= arr[i] <= 1000
Complexity Analysis
- Time Complexity: O(n)
- Space Complexity: O(1)
1550. Three Consecutive Odds LeetCode Solution in C++
class 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;
}
};
/* code provided by PROGIEZ */
1550. Three Consecutive Odds LeetCode Solution in Java
class 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;
}
}
// code provided by PROGIEZ
1550. Three Consecutive Odds LeetCode Solution in Python
class 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
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.