Skip to content

Commit 0dda7d7

Browse files
authored
Create Length of the Longest Alphabetical Continuous Substring.java
1 parent 5072c84 commit 0dda7d7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int longestContinuousSubstring(String s) {
3+
int idx = 0;
4+
int maxLength = 0;
5+
while (idx < s.length()) {
6+
int currIdx = idx++;
7+
while (idx < s.length() && s.charAt(idx) - s.charAt(idx - 1) == 1) {
8+
idx++;
9+
}
10+
maxLength = Math.max(maxLength, idx - currIdx);
11+
}
12+
return maxLength;
13+
}
14+
}

0 commit comments

Comments
 (0)