Skip to content

Commit 837b3c0

Browse files
README_EN.md
1 parent 1371b77 commit 837b3c0

File tree

1 file changed

+19
-0
lines changed
  • solution/2400-2499/2414.Length of the Longest Alphabetical Continuous Substring

1 file changed

+19
-0
lines changed

solution/2400-2499/2414.Length of the Longest Alphabetical Continuous Substring/README_EN.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ int longestContinuousSubstring(char* s) {
195195
return ans;
196196
}
197197
```
198+
###js
199+
```JavaScript
200+
* @param {string} s
201+
* @return {number}
202+
*/
203+
var longestContinuousSubstring = function(s) {
204+
let max = 0, curr = 0, prev = 0, i = 0, c = 0;
205+
206+
while (i < s.length) {
207+
c = s.charCodeAt(i);
208+
curr = (c === prev + 1) ? curr + 1 : 1;
209+
max = (curr > max) ? curr : max;
210+
prev = c;
211+
i++;
212+
}
213+
214+
215+
return max;
216+
};```
198217
199218
<!-- tabs:end -->
200219

0 commit comments

Comments
 (0)