太难了,要是面试的时候碰到这种题,直接寄了。
最简单的办法就是直接调库
class Solution {
public boolean isMatch(String s, String p) {
return s.matches(p);
}
}
dp做法如下:
class Solution {
public boolean isMatch(String s, String p) {
int n = s.length(), m = p.length();
// dp[i - 1][j - 1]表示s[0...i]是否可以和p[0...j]相匹配
boolean[][] dp = new boolean[n + 1][m + 1];
dp[0][0] = true;
for(int i = 0; i
Original: https://www.cnblogs.com/nullpointer-c/p/15886764.html
Author: NullPointer_C
Title: 面试题19. 正则表达式匹配
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/584247/
转载文章受原作者版权保护。转载请注明原作者出处!