新增java 2-D array 建議

This commit is contained in:
Terry Liu
2023-06-15 18:46:08 -04:00
committed by GitHub
parent ff3f402bb8
commit 018c9cb963

View File

@ -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);