Skip to content

Commit 11b1139

Browse files
committed
Runtime: 0 ms (Top 100.0%) | Memory: 2.40 MB (Top 50.0%)
1 parent 53e655c commit 11b1139

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Runtime: 0 ms (Top 100.0%) | Memory: 2.40 MB (Top 50.0%)
2+
3+
impl Solution {
4+
pub fn longest_continuous_substring(s: String) -> i32 {
5+
let mut max = 1;
6+
let mut curr = 1;
7+
let s = s.as_bytes();
8+
for i in 1..s.len() {
9+
if s[i] == s[i-1] + 1 {
10+
curr += 1;
11+
} else {
12+
curr = 1;
13+
}
14+
max = max.max(curr);
15+
}
16+
max as _
17+
}
18+
}

0 commit comments

Comments
 (0)