We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0c1f8c4 commit d47a84eCopy full SHA for d47a84e
1 file changed
06/tasks/task_37_longest_unique_substring.py
@@ -4,4 +4,18 @@ def longest_unique_substring(s: str) -> int:
4
"""
5
Vrátí délku nejdelší podposloupnosti bez opakujících se znaků.
6
7
+ substr = ''
8
+ longest_substring = 0
9
+ for (pos, letter) in enumerate(s):
10
+ if letter in substr:
11
+ len_substr = len(substr)
12
+ pos_duplicate = s.index(letter, pos - len_substr)
13
+ substr = s[pos_duplicate + 1: pos + 1]
14
+ if longest_substring < len_substr:
15
+ longest_substring = len_substr
16
+ else:
17
+ substr += letter
18
+ if longest_substring < len(substr):
19
+ longest_substring = len(substr)
20
21
+ return longest_substring
0 commit comments