I got Memory Limit Exceeded
Following is my code, I don't know what I got the Memory Limit Exceeded error.\n\n\tpublic boolean isMatch(String s, String p) {\n\t\tint lenS = s.length();\n\t
Following is my code, I don't know what I got the Memory Limit Exceeded error.\n\n\tpublic boolean isMatch(String s, String p) {\n\t\tint lenS = s.length();\n\t\tint lenP = p.length();\n\n\t\tboolean[][] dp = new boolean[lenS + 1][lenP + 1];\n\t\tdp[0][0] = true;\n\t\tfor (int i = 1; i <= lenS; i++) {\n\t\t\tfor (int j = 1; j <= lenP; j++) {\n\t\t\t\tif (p.charAt(j - 1) == '*') {\n\t\t\t\t\tdp[i][j] = dp[i - 1][j] || dp[i][j - 1] || dp[i - 1][j - 1];\n\t\t\t\t\tif (j == lenP && dp[i][j]) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t} else if (s.charAt(i - 1) == p.charAt(j - 1)\n\t\t\t\t\t\t|| p.charAt(j - 1) == '?') {\n\t\t\t\t\tdp[i][j] = dp[i - 1][j - 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn dp[lenS][lenP];\n\t}
[]