We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e950990 + 9b52a50 commit c87d709Copy full SHA for c87d709
problems/1035.不相交的线.md
@@ -73,7 +73,24 @@ public:
73
74
75
Java:
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
+ ```
94
95
Python:
96
0 commit comments