일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 시바견
- 파이썬
- 운영체제
- 109. Convert Sorted List to Binary Search Tree
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- attribute
- kaggle
- Generator
- DWG
- data science
- iterator
- Python
- 715. Range Module
- 밴픽
- concurrency
- 프로그래머스
- Protocol
- 30. Substring with Concatenation of All Words
- Python Code
- LeetCode
- shiba
- 43. Multiply Strings
- Class
- Python Implementation
- Decorator
- t1
- Regular Expression
- 컴퓨터의 구조
- 315. Count of Smaller Numbers After Self
Archives
- Today
- Total
Scribbling
LeetCode: 3. Longest Substring Without Repeating Characters 본문
Computer Science/Coding Test
LeetCode: 3. Longest Substring Without Repeating Characters
focalpoint 2021. 8. 11. 17:23class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
char_set = set()
l = 0
max_len = 0
for r in range(len(s)):
if s[r] in char_set:
while s[r] in char_set:
char_set.remove(s[l])
l += 1
char_set.add(s[r])
max_len = max(max_len, r - l + 1)
return max_len
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 5. Longest Palindromic Substring (0) | 2021.08.12 |
---|---|
LeetCode: 787. Cheapest Flights Within K Stops (0) | 2021.08.12 |
LeetCode: 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance (0) | 2021.08.10 |
LeetCode: 743. Network Delay Time (0) | 2021.08.10 |
LeetCode: 2. Add Two Numbers (0) | 2021.08.10 |