Skip to content

Commit c87d709

Browse files
Merge pull request #200 from nmydt/patch-3
添加 1035.不相交的线 Java版本
2 parents e950990 + 9b52a50 commit c87d709

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

problems/1035.不相交的线.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,24 @@ public:
7373
7474
7575
Java:
76-
76+
```java
77+
class Solution {
78+
public int maxUncrossedLines(int[] A, int[] B) {
79+
int [][] dp = new int[A.length+1][B.length+1];
80+
for(int i=1;i<=A.length;i++) {
81+
for(int j=1;j<=B.length;j++) {
82+
if (A[i-1]==B[j-1]) {
83+
dp[i][j]=dp[i-1][j-1]+1;
84+
}
85+
else {
86+
dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
87+
}
88+
}
89+
}
90+
return dp[A.length][B.length];
91+
}
92+
}
93+
```
7794

7895
Python:
7996

0 commit comments

Comments
 (0)