Problems > Wildcard Matching > Editorial

Wildcard Matching — Solution & Editorial

Back to the Problem

DP over prefixes: dp[i][j] = whether T[..i] matches P[..j]. A * either consumes a text character (dp[i−1][j]) or matches empty (dp[i][j−1]); ? and equal characters advance both.

Complexity: O(|T|·|P|)