mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Merge pull request #362 from z80160280/z80160280-patch-11
Update 1035.不相交的线.md
This commit is contained in:
@ -93,7 +93,18 @@ Java:
|
||||
```
|
||||
|
||||
Python:
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
def maxUncrossedLines(self, A: List[int], B: List[int]) -> int:
|
||||
dp = [[0] * (len(B)+1) for _ in range(len(A)+1)]
|
||||
for i in range(1, len(A)+1):
|
||||
for j in range(1, len(B)+1):
|
||||
if A[i-1] == B[j-1]:
|
||||
dp[i][j] = dp[i-1][j-1] + 1
|
||||
else:
|
||||
dp[i][j] = max(dp[i-1][j], dp[i][j-1])
|
||||
return dp[-1][-1]
|
||||
```
|
||||
|
||||
Go:
|
||||
|
||||
|
Reference in New Issue
Block a user