일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 10분
- 월간
- 링피트
- Daily Challenge
- 개발자
- 매일
- 미드시청
- 사이드
- Writing
- 스탭퍼
- 3줄정리
- English
- 운동
- realclass
- 뭐든
- leetcode
- 리얼 클래스
- 읽기
- 영어원서읽기
- 잡생각
- 파비최
- 프로젝트
- 화상영어
- 쓰릴오브파이트
- Problem Solving
- 영어공부
- 30분
- FIT XR
- 괜찮음
- 만화도
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/longest-string-chain/
Longest String Chain - 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
오늘도 시간이 없어서 ㅠㅠ
class Solution:
def longestStrChain(self, words: List[str]) -> int:
dp = {}
res = 1
for word in sorted(words, key=len):
dp[word] = 1
for i in range(len(word)):
prev = word[:i] + word[i + 1 :]
if prev in dp:
dp[word] = dp[prev] + 1
res = max(res, dp[word])
return res
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.06.17 |
---|---|
Today's Challenge (0) | 2022.06.16 |
Today's Challenge (0) | 2022.06.14 |
Today's Challenge (0) | 2022.06.13 |
Today's Challenge (0) | 2022.06.12 |
Comments