diff --git a/problems/0392.判断子序列.md b/problems/0392.判断子序列.md index c10114c0..6342a41f 100644 --- a/problems/0392.判断子序列.md +++ b/problems/0392.判断子序列.md @@ -28,9 +28,9 @@ 两个字符串都只由小写字符组成。 -# 算法公开课 +## 算法公开课 -**《代码随想录》算法视频公开课:[动态规划,用相似思路解决复杂问题 | LeetCode:392.判断子序列](https://www.bilibili.com/video/BV1tv4y1B7ym/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划,用相似思路解决复杂问题 | LeetCode:392.判断子序列](https://www.bilibili.com/video/BV1tv4y1B7ym/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 ## 思路 @@ -149,8 +149,8 @@ public: ## 其他语言版本 +### Java: -Java: ```java class Solution { public boolean isSubsequence(String s, String t) { @@ -174,7 +174,8 @@ class Solution { } ``` -Python: +### Python: + ```python class Solution: def isSubsequence(self, s: str, t: str) -> bool: @@ -190,7 +191,7 @@ class Solution: return False ``` -JavaScript: +### JavaScript: ```javascript const isSubsequence = (s, t) => { @@ -213,7 +214,7 @@ const isSubsequence = (s, t) => { }; ``` -TypeScript: +### TypeScript: ```typescript function isSubsequence(s: string, t: string): boolean { @@ -237,7 +238,7 @@ function isSubsequence(s: string, t: string): boolean { }; ``` -Go: +### Go: ```go func isSubsequence(s string, t string) bool { @@ -266,3 +267,4 @@ func isSubsequence(s string, t string) bool { + diff --git a/problems/0718.最长重复子数组.md b/problems/0718.最长重复子数组.md index 82bf4f59..18cc0240 100644 --- a/problems/0718.最长重复子数组.md +++ b/problems/0718.最长重复子数组.md @@ -25,9 +25,7 @@ ## 算法公开课 -**《代码随想录》算法视频公开课:[动态规划之子序列问题,想清楚DP数组的定义 | LeetCode:718.最长重复子数组](https://www.bilibili.com/video/BV178411H7hV),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 - - +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划之子序列问题,想清楚DP数组的定义 | LeetCode:718.最长重复子数组](https://www.bilibili.com/video/BV178411H7hV),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 ## 思路 @@ -126,7 +124,7 @@ public: * 时间复杂度:O(n × m),n 为A长度,m为B长度 * 空间复杂度:O(n × m) -## 滚动数组 +### 滚动数组 在如下图中: @@ -257,8 +255,8 @@ class Solution { ## 其他语言版本 +### Java: -Java: ```java // 版本一 class Solution { @@ -300,7 +298,7 @@ class Solution { } ``` -Python: +### Python: 2维DP ```python @@ -395,7 +393,8 @@ class Solution: ``` -Go: +### Go: + ```Go func findLength(A []int, B []int) int { m, n := len(A), len(B) @@ -442,7 +441,7 @@ func max(a, b int) int { } ``` -JavaScript: +### JavaScript: > 动态规划 @@ -489,7 +488,7 @@ const findLength = (nums1, nums2) => { } ``` -TypeScript: +### TypeScript: > 动态规划: @@ -544,3 +543,4 @@ function findLength(nums1: number[], nums2: number[]): number { + diff --git a/problems/1035.不相交的线.md b/problems/1035.不相交的线.md index 7142d75c..74e94c84 100644 --- a/problems/1035.不相交的线.md +++ b/problems/1035.不相交的线.md @@ -19,7 +19,7 @@ ## 算法公开课 -**《代码随想录》算法视频公开课:[动态规划之子序列问题,换汤不换药 | LeetCode:1035.不相交的线](https://www.bilibili.com/video/BV1h84y1x7MP),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划之子序列问题,换汤不换药 | LeetCode:1035.不相交的线](https://www.bilibili.com/video/BV1h84y1x7MP),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 ## 思路 @@ -82,8 +82,8 @@ public: ## 其他语言版本 +### Java: -Java: ```java class Solution { public int maxUncrossedLines(int[] nums1, int[] nums2) { @@ -106,7 +106,8 @@ Java: } ``` -Python: +### Python: + ```python class Solution: def maxUncrossedLines(self, A: List[int], B: List[int]) -> int: @@ -120,8 +121,7 @@ class Solution: return dp[-1][-1] ``` - -Golang: +### Go: ```go func maxUncrossedLines(A []int, B []int) int { @@ -152,7 +152,7 @@ func max(a, b int) int { } ``` -Rust: +### Rust: ```rust pub fn max_uncrossed_lines(nums1: Vec, nums2: Vec) -> i32 { @@ -173,7 +173,7 @@ pub fn max_uncrossed_lines(nums1: Vec, nums2: Vec) -> i32 { } ``` -JavaScript: +### JavaScript: ```javascript const maxUncrossedLines = (nums1, nums2) => { @@ -196,7 +196,7 @@ const maxUncrossedLines = (nums1, nums2) => { }; ``` -TypeScript: +### TypeScript: ```typescript function maxUncrossedLines(nums1: number[], nums2: number[]): number { @@ -224,3 +224,4 @@ function maxUncrossedLines(nums1: number[], nums2: number[]): number { + diff --git a/problems/1143.最长公共子序列.md b/problems/1143.最长公共子序列.md index 68269b87..260b085e 100644 --- a/problems/1143.最长公共子序列.md +++ b/problems/1143.最长公共子序列.md @@ -39,7 +39,7 @@ ## 算法公开课 -**《代码随想录》算法视频公开课:[动态规划子序列问题经典题目 | LeetCode:1143.最长公共子序列](https://www.bilibili.com/video/BV1ye4y1L7CQ),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划子序列问题经典题目 | LeetCode:1143.最长公共子序列](https://www.bilibili.com/video/BV1ye4y1L7CQ),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 ## 思路 @@ -136,7 +136,7 @@ public: ## 其他语言版本 -Java: +### Java: ```java /* @@ -207,8 +207,9 @@ class Solution { } ``` -Python: +### Python: 2维DP + ```python class Solution: def longestCommonSubsequence(self, text1: str, text2: str) -> int: @@ -252,7 +253,8 @@ class Solution: ``` -Go: +### Go: + ```Go func longestCommonSubsequence(text1 string, text2 string) int { t1 := len(text1) @@ -283,7 +285,8 @@ func max(a,b int)int { ``` -Javascript: +### JavaScript: + ```javascript const longestCommonSubsequence = (text1, text2) => { let dp = Array.from(Array(text1.length+1), () => Array(text2.length+1).fill(0)); @@ -302,7 +305,7 @@ const longestCommonSubsequence = (text1, text2) => { }; ``` -TypeScript: +### TypeScript: ```typescript function longestCommonSubsequence(text1: string, text2: string): number { @@ -326,7 +329,8 @@ function longestCommonSubsequence(text1: string, text2: string): number { }; ``` -Rust: +### Rust: + ```rust pub fn longest_common_subsequence(text1: String, text2: String) -> i32 { let (n, m) = (text1.len(), text2.len()); @@ -353,3 +357,4 @@ pub fn longest_common_subsequence(text1: String, text2: String) -> i32 { +