From 018c9cb96399a5005f6ed42e0eb69ebc07f24d97 Mon Sep 17 00:00:00 2001 From: Terry Liu <102352821+lozakaka@users.noreply.github.com> Date: 2023年6月15日 18:46:08 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9Ejava=202-D=20array=20?= =?UTF-8?q?=E5=BB=BA=E8=AD=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5254円345円205円261円345円255円220円345円272円217円345円210円227円.md" | 5 +++++ 1 file changed, 5 insertions(+) diff --git "a/problems/1143.346円234円200円351円225円277円345円205円254円345円205円261円345円255円220円345円272円217円345円210円227円.md" "b/problems/1143.346円234円200円351円225円277円345円205円254円345円205円261円345円255円220円345円272円217円345円210円227円.md" index 2b5eed3d2d..68269b87c5 100644 --- "a/problems/1143.346円234円200円351円225円277円345円205円254円345円205円261円345円255円220円345円272円217円345円210円227円.md" +++ "b/problems/1143.346円234円200円351円225円277円345円205円254円345円205円261円345円255円220円345円272円217円345円210円227円.md" @@ -144,6 +144,11 @@ Java: */ class Solution { public int longestCommonSubsequence(String text1, String text2) { + // char[] char1 = text1.toCharArray(); + // char[] char2 = text2.toCharArray(); + // 可以在一開始的時候就先把text1, text2 轉成char[],之後就不需要有這麼多爲了處理字串的調整 + // 就可以和卡哥的code更一致 + int[][] dp = new int[text1.length() + 1][text2.length() + 1]; // 先对dp数组做初始化操作 for (int i = 1 ; i <= text1.length() ; i++) { char char1 = text1.charAt(i - 1); From 342e7a597eb50c1570fdd713a237b761ab777bd6 Mon Sep 17 00:00:00 2001 From: Terry Liu <102352821+lozakaka@users.noreply.github.com> Date: 2023年6月16日 20:58:06 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8A=A0=E5=85=A5B=E7=AB=99=E8=A6=96?= =?UTF-8?q?=E9=A0=BB=E7=B6=B2=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4345円210円240円351円231円244円346円223円215円344円275円234円.md" | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git "a/problems/0583.344円270円244円344円270円252円345円255円227円347円254円246円344円270円262円347円232円204円345円210円240円351円231円244円346円223円215円344円275円234円.md" "b/problems/0583.344円270円244円344円270円252円345円255円227円347円254円246円344円270円262円347円232円204円345円210円240円351円231円244円346円223円215円344円275円234円.md" index 561ad2f238..054f452bf9 100644 --- "a/problems/0583.344円270円244円344円270円252円345円255円227円347円254円246円344円270円262円347円232円204円345円210円240円351円231円244円346円223円215円344円275円234円.md" +++ "b/problems/0583.344円270円244円344円270円252円345円255円227円347円254円246円344円270円262円347円232円204円345円210円240円351円231円244円346円223円215円344円275円234円.md" @@ -14,10 +14,15 @@ * 输入: "sea", "eat" * 输出: 2 -* 解释: 第一步将"sea"变为"ea",第二步将"eat"变为"ea" +* 解释: 第一步将"sea"变为"ea",第二步将"eat"变为"ea" -## 思路 +# 算法公开课 + +**《代码随想录》算法视频公开课:[动态规划之子序列,还是为了编辑距离做铺垫 | LeetCode:583.两个字符串的删除操(https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 + + +## 思路 ### 动态规划一 本题和[动态规划:115.不同的子序列](https://programmercarl.com/0115.不同的子序列.html)相比,其实就是两个字符串都可以删除了,情况虽说复杂一些,但整体思路是不变的。