| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Decorator
- Python Implementation
- attribute
- 30. Substring with Concatenation of All Words
- Python
- 43. Multiply Strings
- LeetCode
- 파이썬
- Regular Expression
- DWG
- 밴픽
- concurrency
- 715. Range Module
- Class
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
- 315. Count of Smaller Numbers After Self
- iterator
- 시바견
- kaggle
- data science
- Substring with Concatenation of All Words
- Python Code
- 컴퓨터의 구조
- Generator
- Convert Sorted List to Binary Search Tree
- t1
- 운영체제
- Protocol
- shiba
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 |