Skip to content

Commit 442a48e

Browse files
authored
Create length-of-the-longest-alphabetical-continuous-substring.py
1 parent d5c8253 commit 442a48e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# string
5+
class Solution(object):
6+
def longestContinuousSubstring(self, s):
7+
"""
8+
:type s: str
9+
:rtype: int
10+
"""
11+
result = l = 0
12+
for i in xrange(len(s)):
13+
l += 1
14+
if i+1 == len(s) or ord(s[i])+1 != ord(s[i+1]):
15+
result = max(result, l)
16+
l = 0
17+
return result

0 commit comments

Comments
 (0)