Question DSA-STR-0010
MediumWhat is the output of this code?
s = "abcabcbb"
seen, start, best = {}, 0, 0
for i, ch in enumerate(s):
if ch in seen and seen[ch] >= start:
start = seen[ch] + 1
seen[ch] = i
best = max(best, i - start + 1)
print(best)
- A.
3
- B.
2
- C.
Sign up free to see the answer and a step-by-step explanation.