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