#1550
Easy Algorithms Three consecutive odds
Array
69.3% acceptance
Feb 25, 2026
1405
106
Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.
Solution
Rust
Time O(1)
Space O(1)
impl Solution {
pub fn three_consecutive_odds(arr: Vec<i32>) -> bool {
arr.windows(3).any(|w| w[0] % 2 == 1 && w[1] % 2 == 1 && w[2] % 2 == 1)
}
}