https://leetcode.com/problems/longest-substring-without-repeating-characters/
Algorithm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Input: s
s is a string and also an list of characters
rst ← 0
n ← length(s)
for i ← 0 to n - 1
dic ← empty set
for length ← 1 to n - i
ss ← s[i:i + length]
for ch in ss[length - 1:] # start from current position
if ch is in dic
go to next i
else
add ch to dic
rst ← max(rst, length(ss))
return rst
Code
1712ms / 13.9MB
PREVIOUSEtc