class Solution:
def LCS(self , str1 , str2 ):
if len(str1) == 1:
return str1
if len(str2) == 1:
return str2
dp = [[0 for i in range(len(str1)+1)] for j in range(len(str2)+1)]
maxlen = 0
for i in range(len(str2)):
for j in range(len(str1)):
if str2[i] == str1[j]:
dp[i+1][j+1] = dp[i][j] + 1
if dp[i+1][j+1] > maxlen:
maxlen = dp[i+1][j+1]
pos = j+1 # position
res = ''
j = pos - maxlen
while j < pos:
res += str1[j]
j += 1
return res
70. 爬楼梯# 滚动数组p q r p q rp = qq = rclass Solution: def climbStairs(self, n: int) -> int: p = 0 q = 1 for i in range(n): r = p + q p = q q = r return ...