- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
- 3. Longest Substring Without Rep
class Solution:
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
arr = [-1 for x in range(128)]
maxx = 0
now = 0
for i in range(len(s)):
now += 1
if arr[ord(s[i])] > -1:
now = min(now, i - arr[ord(s[i])])
maxx = max(maxx, now)
arr[ord(s[i])] = i
maxx = max(maxx, now)
return maxx
网友评论