일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 30분
- 프로젝트
- English
- 월간
- Writing
- 영어원서읽기
- Daily Challenge
- leetcode
- 잡생각
- 괜찮음
- 만화도
- 뭐든
- FIT XR
- 10분
- 사이드
- 링피트
- 쓰릴오브파이트
- 스탭퍼
- 리얼 클래스
- 읽기
- 개발자
- 미드시청
- realclass
- 영어공부
- 매일
- 화상영어
- 파비최
- 운동
- Problem Solving
- 3줄정리
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