Longest Substring Without Repeating Characters
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
q = []
max = 0
for i in range(len(s)):
for j in list(s)[i:]:
if j not in q:
q.append(j)
else:
if max < len(q):
max = len(q)
q = []
break
else:
if max < len(q):
max = len(q)
q = []
return max
if __name__ == "__main__":
print(Solution().lengthOfLongestSubstring("pwwkew"))
Comments