Consecutive Characters LeetCode solution in Rust

1
impl Solution {
2
pub fn max_power(s: String) -> i32 {
3
s.into_bytes()
4
.windows(2)
5
.scan(1, |s, x| {
6
*s = if x[0] == x[1] { *s + 1 } else { 1 };
7
Some(*s)
8
})
9
.max()
10
.unwrap_or(1)
11
}
12
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0