반응형
1. Problem : https://py.checkio.org/en/mission/longest-substring-of-unique-characters/
2. My solution
def longest_substr(s: str) -> int:
# your code here
no_repeat_list = []
longest = 0
for char in [*s]:
if no_repeat_list.count(char) == 0: no_repeat_list.append(char)
else:
index = no_repeat_list.index(char)+1
no_repeat_list.append(char)
no_repeat_list = no_repeat_list[index:]
if len(no_repeat_list) > longest: longest = len(no_repeat_list)
return longest
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[CheckIO/Scientific Expedition] Pangram (0) | 2024.03.24 |
---|---|
[CheckIO][Scientific Expedition] Latest-iso-datetime (0) | 2024.02.18 |
[CheckIO] Replace All Occureences (0) | 2024.02.18 |
[CheckIO] Convert To Title case (0) | 2024.02.18 |
[CheckIO] Count Vowels (0) | 2024.02.18 |
댓글