| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 리얼 클래스
- Problem Solving
- 뭐든
- 괜찮음
- 미드시청
- leetcode
- 만화도
- realclass
- 화상영어
- 파비최
- 운동
- 30분
- 10분
- 프로젝트
- 영어공부
- English
- Writing
- 개발자
- 잡생각
- 링피트
- 영어원서읽기
- 매일
- Daily Challenge
- 읽기
- 사이드
- 3줄정리
- FIT XR
- 월간
- 스탭퍼
- 쓰릴오브파이트
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/longest-substring-without-repeating-characters/
Longest Substring Without Repeating Characters - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
어제에 이어서 오늘도 Two Pointer 문제.
지난주 스터디에서 작성했던 소스 참고해서 내 힘으로 품!! 오예~~
(5번 WA 뜬 건 안 비밀.....)
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
ar = [0] * 128
l = len(s)
left, right = 0, 0
res = 0
if l == 0:
return 0
if l == 1:
return 1
while left <= right:
if ar[ord(s[right])] == 0:
ar[ord(s[right])] += 1
right += 1
elif ar[ord(s[right])] > 0:
ar[ord(s[left])] -= 1
left += 1
res = max(res, right-left)
if right == l:
break
return res반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2022.06.12 |
|---|---|
| Today's Challenge (0) | 2022.06.11 |
| Today's Challenge (0) | 2022.06.09 |
| Today's Challenge (0) | 2022.06.08 |
| Today's Challenge (0) | 2022.06.07 |
Comments