leetcode1035】的更多相关文章

We write the integers of A and B (in the order they are given) on two separate horizontal lines. Now, we may draw a straight line connecting two numbers A[i] and B[j] as long as A[i] == B[j], and the line we draw does not intersect any other connecti…
class Solution: def maxUncrossedLines(self, A: 'List[int]', B: 'List[int]') -> int: m = len(A) n = len(B) dp = [[0 for a in range(n+1)] for b in range(m+1)] for i in range(1,m+1): for j in range(1,n+1): if A[i-1] == B[j-1]: dp[i][j] = dp[i-1][j-1] +…