原理
闫氏DP分析法yyds!
一图胜千言~
代码
原理很复杂,代码却很简洁,就是这种高级感啊....
n,m = map(int,input().split())
a = " "+input()
b = " "+input()
f = [[0 for i in range(len(b)+1)] for j in range(len(a)+1)]
for i in range(1,len(a)):
for j in range(1,len(b)):
f[i][j] = max(f[i-1][j], f[i][j-1])
if a[i] == b[j]: f[i][j] = max(f[i][j],f[i-1][j-1]+1)
print(f[n][m])
大佬,磕一个!
orz%%%
大佬牛逼,写的太好了
神犇%%%%
666
AcWing《第二届ACC(AcWing Cup)全国联赛》拼团优惠!https://www.acwing.com/activity/content/introduction/3043/group_buy/138024/
我要狠狠的收藏
谢谢喜欢~