MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / three_consecutive_odds

Function three_consecutive_odds

1550-three-consecutive-odds.rs:1–17  ·  view source on GitHub ↗
(arr: Vec<i32>)

Source from the content-addressed store, hash-verified

1pub fn three_consecutive_odds(arr: Vec<i32>) -> bool {
2 pub fn is_odd(num: i32) -> bool {
3 num % 2 != 0
4 }
5 let mut count = 0;
6 for i in 0..arr.len() {
7 if is_odd(arr[i]) {
8 count += 1;
9 } else {
10 count = 0;
11 }
12 if count == 3 {
13 return true;
14 }
15 }
16 false
17}
18
19fn main() {
20 let arr = vec![1,1,1];

Callers

nothing calls this directly

Calls 1

is_oddFunction · 0.85

Tested by

no test coverage detected