Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first = input()
- second = input()
- rows = len(first) + 1
- cols = len(second) + 1
- dp = [[0] * cols for _ in range(rows)]
- for row in range(1, rows):
- for col in range(1, cols):
- if first[row-1] == second[col -1]:
- dp[row][col] = dp[row-1][col-1] + 1
- else:
- dp[row][col] = max(dp[row-1][col], dp[row][col-1])
- print(dp[rows-1][cols-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement