Problem 3 and 4

This commit is contained in:
Simon Oberzier
2026-01-08 22:45:44 +01:00
parent 293fee1fc5
commit 3ebdf3d3b9
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
count = 0
current = []
solutions = {}
for c in s:
if c in current:
solutions[count] = current
idx = current.index(c)
current = current[idx + 1:]
count -= idx + 1
current.append(c)
count += 1
solutions[count] = current
return max(solutions.keys())