From 2c105b62ac5858ab5cf6326c1591c544c4f474ae Mon Sep 17 00:00:00 2001 From: Vanshika Gupta Date: Tue, 25 Oct 2022 23:07:25 +0530 Subject: [PATCH] Added solution to the cpp folder for the problem wildcard-matching --- src/cpp/wildcard-matching.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/cpp/wildcard-matching.cpp 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