Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def lengthOfLongestSubstring(self, s: str) -> int:
- if len(s) == 0:
- return 0
- result = 1
- length_str = len(s)
- s = list(s)
- a = 0
- while True:
- a += 1
- if len(s) != length_str:
- length_str = len(s)
- a = 1
- if a == len(s) or result == 95:
- return result
- tmp = 1
- for k in range(0, a):
- if len(s) == 1:
- return result if result > 1 else 1
- if s[k] == s[a]:
- s = s[k+1:]
- break
- else:
- tmp += 1
- if tmp > result:
- result = tmp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement