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

Function max_power

1446-consecutive-characters.rs:1–17  ·  view source on GitHub ↗
(s: String)

Source from the content-addressed store, hash-verified

1pub fn max_power(s: String) -> i32 {
2 let mut current_char = '!';
3 let mut current_len = 1;
4 let mut ret = 0;
5 for c in s.chars() {
6 if c == current_char {
7 current_len += 1;
8 } else {
9 current_len = 1;
10 current_char = c;
11 }
12 if current_len > ret {
13 ret = current_len;
14 }
15 }
16 ret
17}
18
19fn main() {
20 let s = "leetcode".to_string();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected