Merge pull request #385 from yang170/patch-5

Update 0718.最长重复子数组.md
This commit is contained in:
程序员Carl
2021-06-12 16:26:55 +08:00
committed by GitHub

View File

@ -154,7 +154,25 @@ public:
Java
```java
class Solution {
public int findLength(int[] nums1, int[] nums2) {
int result = 0;
int[][] dp = new int[nums1.length + 1][nums2.length + 1];
for (int i = 1; i < nums1.length + 1; i++) {
for (int j = 1; j < nums2.length + 1; j++) {
if (nums1[i - 1] == nums2[j - 1]) {
dp[i][j] = dp[i - 1][j - 1] + 1;
max = Math.max(max, dp[i][j]);
}
}
}
return result;
}
}
```
Python