[LeetCode] 3. Longest Substring Without Repeating Characters
Python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
answer = 0
temps = []
for i in s:
if i in temps:
temps = temps[temps.index(i) + 1:]
temps.append(i)
answer = max(answer, len(temps))
return answer
댓글남기기