) -> i32 {
-
From bf457f49bb1961bc0013283b8b9678363a9a7207 Mon Sep 17 00:00:00 2001
From: a12bb <2713204748@qq.com>
Date: Wed, 13 Mar 2024 22:04:23 +0800
Subject: [PATCH 24/26] =?UTF-8?q?Update=200674.=E6=9C=80=E9=95=BF=E8=BF=9E?=
=?UTF-8?q?=E7=BB=AD=E9=80=92=E5=A2=9E=E5=BA=8F=E5=88=97.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
0674.最长连续递增序列新增C语言实现
---
problems/0674.最长连续递增序列.md | 52 ++++++++++++++++++++++-
1 file changed, 51 insertions(+), 1 deletion(-)
diff --git a/problems/0674.最长连续递增序列.md b/problems/0674.最长连续递增序列.md
index 485e321c..ece62944 100644
--- a/problems/0674.最长连续递增序列.md
+++ b/problems/0674.最长连续递增序列.md
@@ -425,6 +425,57 @@ function findLengthOfLCIS(nums: number[]): number {
};
```
+### C:
+
+> 动态规划:
+
+```c
+int findLengthOfLCIS(int* nums, int numsSize) {
+ if(numsSize == 0){
+ return 0;
+ }
+ int dp[numsSize];
+ for(int i = 0; i < numsSize; i++){
+ dp[i] = 1;
+ }
+ int result = 1;
+ for (int i = 1; i < numsSize; ++i) {
+ if(nums[i] > nums[i - 1]){
+ dp[i] = dp[i - 1] + 1;
+ }
+ if(dp[i] > result){
+ result = dp[i];
+ }
+ }
+ return result;
+}
+```
+
+
+
+> 贪心:
+
+```c
+int findLengthOfLCIS(int* nums, int numsSize) {
+ int result = 1;
+ int count = 1;
+ if(numsSize == 0){
+ return result;
+ }
+ for (int i = 1; i < numsSize; ++i) {
+ if(nums[i] > nums[i - 1]){
+ count++;
+ } else{
+ count = 1;
+ }
+ if(count > result){
+ result = count;
+ }
+ }
+ return result;
+}
+```
+
@@ -432,4 +483,3 @@ function findLengthOfLCIS(nums: number[]): number {
-
From 00a5515bad938f6c3ff32e3f88c5639346c0f947 Mon Sep 17 00:00:00 2001
From: a12bb <2713204748@qq.com>
Date: Wed, 13 Mar 2024 22:05:38 +0800
Subject: [PATCH 25/26] =?UTF-8?q?Update=200718.=E6=9C=80=E9=95=BF=E9=87=8D?=
=?UTF-8?q?=E5=A4=8D=E5=AD=90=E6=95=B0=E7=BB=84.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
0178.最长重复子数组新增C语言实现
---
problems/0718.最长重复子数组.md | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/problems/0718.最长重复子数组.md b/problems/0718.最长重复子数组.md
index 272cf2b2..e00b3ded 100644
--- a/problems/0718.最长重复子数组.md
+++ b/problems/0718.最长重复子数组.md
@@ -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;
+}
+```
+
-
From fac689939f7c6a31f11198a4ecccfa3d0f2bee6a Mon Sep 17 00:00:00 2001
From: a12bb <2713204748@qq.com>
Date: Wed, 13 Mar 2024 22:08:15 +0800
Subject: [PATCH 26/26] =?UTF-8?q?Update=201143.=E6=9C=80=E9=95=BF=E5=85=AC?=
=?UTF-8?q?=E5=85=B1=E5=AD=90=E5=BA=8F=E5=88=97.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1143.最长公共子序列新增C语言实现
---
problems/1143.最长公共子序列.md | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/problems/1143.最长公共子序列.md b/problems/1143.最长公共子序列.md
index f33391c3..12bd90f8 100644
--- a/problems/1143.最长公共子序列.md
+++ b/problems/1143.最长公共子序列.md
@@ -376,10 +376,32 @@ impl Solution {
}
```
+### C:
+
+```c
+#define max(a, b) ((a) > (b) ? (a) : (b))
+
+int longestCommonSubsequence(char* text1, char* text2) {
+ int text1Len = strlen(text1);
+ int text2Len = strlen(text2);
+ int dp[text1Len + 1][text2Len + 1];
+ memset(dp, 0, sizeof (dp));
+ for (int i = 1; i <= text1Len; ++i) {
+ for (int j = 1; j <= text2Len; ++j) {
+ if(text1[i - 1] == text2[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[text1Len][text2Len];
+}
+```
+
-