LIS 套路
azl397985856 opened this issue · 1 comments
azl397985856 commented
-
[1048] 最长字符串链
wizard 套路
class Solution:
def longestStrChain(self, words):
dic = {}
words.sort(key=len)
ans = 1
for word in words:
dic[word] = 1
for i in range(len(word)):
new_word = word[:i] + word[i + 1 :]
if new_word in dic:
dic[word] = max(dic[new_word] + 1, dic[word])
ans = max(ans, dic[word])
return ans
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.