一题一句:注意dp matrix 的行列数是比s1,s2的长度多出1的。所以dp[i][j] 对应的s1.charAt(i-1), s2.charAt(j-1)
补充,这个题目recursion解法会ETL,但是true/false返回值的方式值得思考。
public class Solution {
public boolean isInterleave(String s1, String s2, String s3) {
// Note: The Solution object is instantiated only once and is reused by each test case.
if (s1.length() + s2.length() != s3.length()) return false;
boolean[][] dp = new boolean[s1.length() + 1][s2.length() + 1];
dp[0][0] = true;
for(int i = 1; i