Skip to content

Commit e55680b

Browse files
committed
src/bin/max-consecutive-ones.rs
1 parent cdf2731 commit e55680b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/bin/max-consecutive-ones.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
fn main() {}
2+
3+
struct Solution;
4+
5+
impl Solution {
6+
pub fn find_max_consecutive_ones(nums: Vec<i32>) -> i32 {
7+
let mut r = 0;
8+
let mut count = 0;
9+
10+
for i in nums {
11+
if i == 1 {
12+
count += 1;
13+
} else {
14+
r = r.max(count);
15+
count = 0
16+
}
17+
}
18+
r
19+
}
20+
}

0 commit comments

Comments
 (0)