Update 0718.最长重复子数组.md

0178.最长重复子数组新增C语言实现
This commit is contained in:
a12bb
2024-03-13 22:05:38 +08:00
parent bf457f49bb
commit 00a5515bad

View File

@ -560,10 +560,30 @@ impl Solution {
}
```
### C:
```c
int findLength(int* nums1, int nums1Size, int* nums2, int nums2Size) {
int dp[nums1Size + 1][nums2Size + 1];
memset(dp, 0, sizeof(dp));
int result = 0;
for (int i = 1; i <= nums1Size; ++i) {
for (int j = 1; j <= nums2Size; ++j) {
if(nums1[i - 1] == nums2[j - 1]){
dp[i][j] = dp[i - 1][j - 1] + 1;
}
if(dp[i][j] > result){
result = dp[i][j];
}
}
}
return result;
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>