diff --git a/src/cpp/wildcard-matching.cpp b/src/cpp/wildcard-matching.cpp new file mode 100644 index 0000000..356678e --- /dev/null +++ b/src/cpp/wildcard-matching.cpp @@ -0,0 +1,34 @@ +class Solution { + +public: + bool isMatch(string s, string p) { + + int n = s.size(); + int m = p.size(); + + vector> dp(n+1, vector (m+1,false)); //vector used for memoization + //dp[i][j] will store the output (possible/ not possible) for strings of length i and j, considering we take only the first i and j characters of given strings s and p respectively into consideration + + // base cases + dp[0][0] = true; + for(int j=1; j<=m; j++){ + dp[0][j] = true; + for(int i=0; i