id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string &s, string &p) {\n string bp;\n char l = '\\0';\n for(char &c: p){\n if(c == '*' && l == '*') continue;\n l = c;\n bp.push_back(c);\n }\n int i = 0; int j = 0;\n int si; int sj = -1... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int i = 0, j = 0, last_match = 0;\n int star = -1;\n while (i < s.size()) {\n if (j < p.size() && (s[i] == p[j] || p[j] == '?')) {\n i++;\n j++;\n } else if (j < p.si... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int s_len = s.size(), p_len = p.size();\n int s_index = 0, p_index = 0;\n int star_index = -1, s_tmp_index = -1;\n\n while (s_index < s_len) {\n if (p_index < p_len && (p[p_index] == '?' || p[p_index]... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string pattern, string wild) {\n \n int n = wild.length();\n int m = pattern.length();\n int i = 0;\n int j = 0;\n int checkw = -1;\n int checkp = -1;\n \n \n while(i... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string text, string pattern) \n {\n int plen=pattern.size();\n int tlen=text.size();\n int pIndex=0,tIndex=0;\n int pStarIndex=-1,tStartIndex=-1;\n\n while(tIndex<tlen)\n {\n if(pIndex<plen&&(text[tIndex]==p... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int n = s.size();\n int m = p.size();\n bool* prev = new bool[m+1];\n bool* curr = new bool[m+1];\n fill(prev, prev+m+1, false);\n fill(curr, curr+m+1, false);\n prev[0] = true;\n for... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\n string removeConsecutiveStars(string& p)\n {\n if(p == \"\")\n return p;\n\n string res;\n res += p[0];\n for(int i=1; i<p.size(); i++)\n {\n if(p[i] == '*' && p[i] == p[i-1])\n continue;\n \n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n // NO RECURSION: it's not needed as our regex is not very complicated,\n // so let's skip catastrophic backtracking our PATTERN is composed of\n // disjoint GROUPS that must precede each other; the GROUPS are split by\... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int n = s.length(), m = p.length();\n vector<bool> dp(m + 1, false), curr(m + 1, false);\n dp[0] = true;\n for(int i = 1; i <= m; i++){\n if(p[i - 1] == '*')\n dp[i] = dp[i - 1];\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int m = s.size(), n = p.size();\n vector<bool> prev(n + 1, false);\n vector<bool> curr(n + 1, false);\n\n prev[0] = true;\n int j = 0;\n while(j < n && p[j] == '*') prev[j + 1] = true, j++;\n\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n//Method 1 - TopDown(Memoization) -- TC = O(n*m) and SC = O(n*m) + O(n+m)\n//Memory limit exceeded\n // bool solve(string s,string p,int i,int j,vector<vector<int>> &dp)\n // {\n // if(i<0 && j<0) return true;\n // else if(i>=0 && j<0) return false;\n // ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n int solve(string &s, string &p, int n, int m, vector<vector<int>>& dp){\n if(n == 0 && m == 0) return true;\n if(n == 0 && m > 0) return false;\n if(n > 0 && m == 0){\n bool flag = true;\n for(int i = 1; i <= n; i++){\n if(s[i-1] ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n string s1 = p;\n string s2 = s;\n int n = s1.size();\n int m = s2.size();\n vector<bool> prev(m + 1, false), cur(m + 1, false);\n\n prev[0] = true;\n\n for(int i = 1; i <= n; i++){\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n vector<string> tokens{};\n string token = \"\";\n for(char c: p) {\n if(c == '*') {\n if(tokens.size() > 0 && tokens.back() == \"*\" && token.size() == 0) {\n // consecutive... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n const int n = (int)s.length();\n \n vector<bool> dp(n + 1, false);\n dp[0] = true;\n \n for (auto& ch : p) {\n vector<bool> newDp(n + 1, false);\n if (ch == '?') {\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n int f(int i, int j, string pat, string str){\n\n if(i < 0 && j < 0) return true;\n else if(i < 0 && j >= 0) return false;\n else if(i >= 0 && j < 0){\n for(int k=0; k<=i; k++){\n if(pat[k] != '*') return false;\n }\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n int ssize;\n int psize;\n bool sol;\n vector<bool> visited;\n bool isMatch(string s, string p) {\n \n ssize = s.size();\n psize = p.size();\n if (psize == 0 || ssize == 0) visited = vector<bool>(1);\n else visited = vector<bool>(... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n int ssize;\n int psize;\n bool sol;\n vector<bool> visited;\n bool isMatch(string s, string p) {\n \n ssize = s.size();\n psize = p.size();\n if (psize == 0 || ssize == 0) visited = vector<bool>(1);\n else visited = vector<bool>(... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n /*\n Space optimizacija Memoizacije.Trenutni red ces generisati na osnovu prethodnog.Stoga \n Space Complexity : O(M) , Time Complexity : O(N*M) \n */\n bool isMatch(const string &s, const string &p) {\n int n = s.size();\n int m = p.size();\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int n = s.length();\n int m = p.length();\n vector<bool> prev(n+1,false);\n // vector<bool> dp(n+1,false);\n prev[0]=true;\n\n for(int i = 1; i<=m; i++){\n vector<bool> dp(n+1, false); /... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool dp[2005][2005];\n\n bool isMatch(string &s, string &p,int sc=0,int pc=0) {\n if(dp[sc][pc])return false;\n if(sc>s.length())return false;\n if(pc==p.length()&&sc==s.length())return true;\n\n if(pc<p.length()&&p[pc]=='*'){\n if(pc... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool dp[2001][2001] ;\n bool isMatchHelper(int i, int j, string s, string p){\n if(i < 0 && j < 0) return true ; // Both String Exhausted\n if(i >= 0 && j < 0) return false ; // string s got exhausted\n if(i < 0){ // string p must have all '*'... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool matchPos[2000][2000];\npublic:\n bool isMatch(string s, string p) {\n if(p == \"*\"){\n return true;\n }\n if(s.length() == 0){\n for(int i = 0; i < p.length(); i++){\n if(p[i] != '*'){\n ret... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n int helper(string s, string p, int i, int j, vector<vector<int>>& dp){\n if(i < 0 && j < 0){\n return 1;\n }\n if (i < 0) { \n for (int k = 0; k <= j; k++)\n if (p[k] != '*') return 0;\n return 1;\n }... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n // bool solve(int i, int j, string &p, string &s, vector<vector<int>>& dp){\n // //base case\n // if(i == 0 && j ==0) return true;\n // if(i==0 && j>0) return false;\n // if(j==0 && i>0){\n // for(int k = 0; k<i; k++){\n // ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n if (p.empty()) {\n return s.empty();\n }\n \n string r = \"\";\n for (char c: p) {\n if (c == '*' &&\n !r.empty() && r.back() == '*') {\n continue;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n bool dp[2001][2001] ={};\n dp[0][0] = 1;\n for(int i = 1 ; i <= p.size() ; i++)\n {\n if(p[i -1 ] == '*')\n dp[i][0] = dp[i-1][0];\n for(int j = 1 ; j <= s.size() ; j++)\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int m = s.size(), n = p.size();\n vector<vector<bool>> dp(n+1, vector<bool>(m+1, false));\n dp[0][0] = true;\n for(int i = 1; i <= n; i++){\n if(p[i-1] == '*'){\n dp[i][0] = dp[i-1][0];... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n int solve(string &s, string &p, int n, int m, vector<vector<int>>& dp){\n if(n == 0 && m == 0) return true;\n if(n == 0 && m > 0) return false;\n if(n > 0 && m == 0){\n bool flag = true;\n for(int i = 1; i <= n; i++){\n if(s[i-1] ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool solve(int i, int j, string s, string p){\n \n if(i == 0 && j==0) return true; \n if(i == 0 && j>0) return false; \n if(j == 0){\n for(int k = 1; k<=i; k++) if(s[k - 1] != '*') return false;\n return true;\n }\n\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n \n// bool f(int index1,int index2,string s, string p,vector<vector<int>>& dp){\n// if(index1<0&&index2<0) return true;\n// if(index1<0&&index2>=0){\n// //this means pattern is finished string is not \n// return false;\n// }\n// if(index1>=0... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\n bool ismatch(int i, int j, string& s1, string& s2,\n vector<vector<int>>& dp) {\n // base case;\n if (i < 0 and j < 0)\n return true;\n if (i < 0 and j >= 0)\n return false;\n if (j < 0 and i >= 0) {\n for (i... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isAllStar(int i,string p){\n for (int j = 1; j <= i; j++) {\n if (p[j - 1] != '*')\n return false;\n }\n return true;\n }\n bool solve(int i,int j,string s,string p,vector<vector<int>> &dp){\n if(i<0 && j<0) return true;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n if (s.empty()) {\n return (p.empty() || count(p.begin(), p.end(), '*') == p.size());\n }\n else if (p.empty()) return false;\n if (p[0] != '*' && p[0] != '?' && p[0] != s[0]) return false;\n in... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n\n bool rightmatch(const char* s, const char* p, set<pair<const char*, const char*>>& visited) {\n\n \n while (*s) {\n if (*s == *p || *p == '?') {\n if (visited.contains(make_pair(s, p))) {\n return false;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\nbool is(string s,int k){\n for(int i=k-1;i>=0;i--){\n if(s[i]!='*'){\n return false;\n }\n }\n return true;\n}\n bool isMatch(string p, string s) {\n int n=s.size();\n int m=p.size();\n vector<int>pr(m+1,false);\n vector<int>c(... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "\nclass Solution {\npublic:\n bool isMatch(string s, string p) {\n int m = s.size(), n = p.size();\n int f[m + 1][n + 1];\n memset(f, -1, sizeof(f));\n function<bool(int, int)> dfs = [&](int i, int j) {\n if (i >= m) {\n return j >= n || (p[j] == '*'... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "\nclass Solution {\npublic:\n bool isMatch(const std::string& s, const std::string& p) {\n int m = s.size();\n int n = p.size();\n std::vector<std::vector<bool>> dp(m + 1, std::vector<bool>(n + 1, false));\n dp[0][0] = true;\n \n for (int j = 1; j <= n; ++j)... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n\n bool isMatch(string s, string p) {\n\n vector<vector<bool>> dp(s.size() + 1, vector(p.size() + 1, false));\n\n dp[0][0] = true;\n\n for (int j = 0; j < p.size() && p[j] == '*'; ++j) {\n dp[0][j + 1] = true;\n }\n \n for (... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\n\npublic:\n\n bool isMatch(string s, string p) {\n\n vector<vector<bool>> dp(s.size() + 1, vector(p.size() + 1, false));\n\n dp[0][0] = true;\n\n for (int j = 0; j < p.size() && p[j] == '*'; ++j) {\n\n dp[0][j + 1] = true;\n\n }\n\n \n\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\n\n public:\n\n bool isMatch(string s, string p) {\n\n const int m = s.length();\n\n const int n = p.length();\n\n // dp[i][j] := true if s[0..i) matches p[0..j)\n\n vector<vector<bool>> dp(m + 1, vector<bool>(n + 1));\n\n dp[0][0] = true;\n\n auto isMatch = [&](int i, i... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 0 | {
"code": "class Solution {\npublic:\n//Method 1 - TopDown(Memoization) -- TC = O(n*m) and SC = O(n*m) + O(n+m)\n // bool solve(string s,string p,int i,int j,vector<vector<int>> &dp)\n // {\n // if(i<0 && j<0) return true;\n // else if(i>=0 && j<0) return false;\n // else if(i<0 && j>=0)\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\n public:\n bool isMatch(string s, string p) {\n const int m = s.length();\n const int n = p.length();\n // dp[i][j] := true if s[0..i) matches p[0..j)\n vector<vector<bool>> dp(m + 1, vector<bool>(n + 1));\n dp[0][0] = true;\n\n auto isMatch = [&](int i, int j) -> bool ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\nprivate:\n string compress(string s) {\n int n = s.length();\n string ret = \"\";\n ret += s[0];\n for (int i = 1; i < n; i++) {\n if (!(s[i] == '*' and s[i-1] == '*')) {\n ret += s[i];\n }\n }\n return ret;... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\nbool helper(int i , int j , string text1, string text2 , vector<vector<int>> &dp){\n int n = text1.size();\n int m = text2.size();\n\n if(i == n && j == m){\n return true;\n }\n\n if(j == m && i<n){\n return false;\n }\n\n if(i == n && j<m){\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n s=\" \"+s;\n p=\" \"+p;\n int n=s.size();\n int m=p.size();\n vector<vector<bool>>dp(n+1,vector<bool>(m+1,false));\n dp[0][0]=true;\n for(int i=1;i<=p.size()-1;i++){\n if(p[i]=='*... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool findAnsRecur(string s, string p, int row, int col, vector<vector<int>> &dp){\n if(row < 0 && col < 0) return true;\n\n if(row < 0) {\n for(int i=0;i<=col;i++) if(p[i] != '*') return false;\n return true;\n }\n if(col < 0)... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n // bool solve(string& s, string& p, int i, int j, vector<vector<bool>>& dp) {\n // if (i == s.size() && j == p.size())\n // return true;\n // if (j == p.size())\n // return false;\n // if (i == s.size()) {\n // while (j < ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n // bool help(int i,int j,string &s,string &t,vector<vector<int>>&dp){\n // if(i<0&&j<0) return true;\n // if(i>=0&&j<0) return false;\n // if(i<0&&j>=0){\n // for(int k=0;k<=j;k++){\n // if(t[k]!='*') return false;\n // ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n // bool help(int i,int j,string &s,string &t,vector<vector<int>>&dp){\n // if(i<0&&j<0) return true;\n // if(i>=0&&j<0) return false;\n // if(i<0&&j>=0){\n // for(int k=0;k<=j;k++){\n // if(t[k]!='*') return false;\n // ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n vector<vector<bool>> dp(s.size() + 1, vector<bool>(p.size() + 1, false));\n unordered_set<int> sett;\n dp[0][0] = true;\n for(int j=0; j<p.size() && p[j] == '*'; j++) {\n dp[0][j+1] = true;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int n=s.size(),m=p.size();\n string pattern=\"\";\n if(m>0)\n pattern=pattern+p[0];\n for(int i=1;i<m;i++){\n if(p[i]=='*' && p[i-1]=='*') continue;\n else\n pattern=patte... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool Solve(int i, int j, string &s, string &p, int (*dp)[2001]) {\n\n if (dp[i][j] != -1) {\n return dp[i][j];\n }\n\n if (i == 0 and j == 0) {\n return dp[i][j] = 1;\n }\n\n if (j == 0 and i > 0) {\n return ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\n int idx;\n bool dp[2005][2005], vis[2005][2005];\n bool sol(int i, int j, string& s, string& t) {\n if ((i == s.size() || i >= idx) && j == t.size())\n return true;\n\tbool& ret = dp[i][j];\n\tif (vis[i][j])\n\t\treturn ret;\n\tvis[i][j] = true;\n\tif (s[i] == '?' || s... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n // Function to check if a substring of p contains only '*'\n bool isAllStars(string p, int i) {\n for (int j = 0; j < i; j++) {\n if (p[j] != '*')\n return false;\n }\n return true;\n }\n\n bool isMatch(string s, string ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isallstars(string p,int i){\n for(int j=1;j<=i;j++){\n if(p[j-1]!='*'){\n return false;\n }\n }\n return true;\n }\n bool isMatch(string s, string p) {\n int n=s.size();\n int m=p.size();\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool allstars(string p,int i){\n for(int j=1;j<=i;j++)\n if(p[j-1]!='*')\n return false;\n return true;\n }\n bool util(string s,string p,vector<vector<bool>>& dp,int n,int m){\n // if(n<0 && m<0)\n // return tru... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n vector<vector<char>> memo(s.size()+1, vector<char>(p.size(), 2));\n return dfsMemo(s, p, 0, 0, memo);\n }\n \n bool dfsMemo(const string& s, const string& p, int i, int j, \n vector<vector<char>>& mem... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool cal(int i, int j, string& s, string& p,vector<vector<char>> &dp) {\n if(j==p.size()) return i==s.size();\n if(dp[i][j]!=-1) return dp[i][j];\n if(p[j]=='*') \n return dp[i][j]=cal(i,j+1,s,p,dp)||(i<s.size() && cal(i+1,j,s,p,dp));\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n \n // bool solve(string &s, string &p, int i, int j)\n // {\n // else if(j==0)\n // {\n // t[i][j] = 0;\n // return false;\n // }\n // else if(i==0)\n // {\n // int ans = true;\n // for(int k... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int dp[2001][2001];\n dp[0][0] = 1;\n int flag = 1;\n for(int i = 0; i <= s.size(); i++) {\n for(int j = 0; j <= p.size(); j++) {\n if(i == 0 and j == 0) continue;\n if(j... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n string st,pa = \"\";\n set<pair<int,int>> dp;\n bool solve(int idx1, int idx2){\n if(dp.contains({idx1,idx2}))\n return false;\n dp.emplace(idx1,idx2);\n while(idx1 < st.size()){\n if(pa[idx2] == '?');\n else if(pa[i... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "\nclass Solution {\npublic:\n\tbool isMatch(string s, string p) {\n\t\tint n = s.length(), m = p.length();\n\t\tint dp[2002][2002];\n\n\t\tdp[0][0] = 1;\n\n\t\tfor (int i = 1; i <= n; i = i + 1) {\n\t\t\tdp[i][0] = 0;\n\t\t}\n\n\t\tbool flag = 1;\n\t\tfor (int j = 1; j <= m; j = j + 1) {\n\n\t\t\tif (p[j -... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\n // Tabulation Solution\n bool allStar(string p, int j){\n for(int i=j; i>=0; i--){\n if(p[i] != '*')\n return false;\n }\n return true;\n }\npublic:\n bool isMatch(string s, string p) {\n int m = s.size(), n = p.size();\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool f(int i,int j, string s,string p,vector<vector<int>>&dp){\n if(i==0 && j==0) return true;\n if(i>0 && j==0) return false;\n if(i==0 && j>0){\n for(int k=1;k<=j;k++){\n if(p[k-1]!='*'){\n return false;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool f(int i,int j, string s,string p,vector<vector<int>>&dp){\n if(i==0 && j==0) return true;\n if(i>0 && j==0) return false;\n if(i==0 && j>0){\n for(int k=1;k<=j;k++){\n if(p[k-1]!='*'){\n return false;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n\n bool allstars(string p, int m){\n while(m>=0){\n if(p[m] !='*'){\n return false;\n }\n m--;\n }\n\n return true;\n }\n\n bool recur(string& s, string& p,int n, int m, vector<vector<int>>& dp){\n\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n return tabul(s,p);\n vector<vector<bool>> mem(s.length(),vector<bool>(p.length(),false));\n return rec(0,0,s,p,mem);\n }\n bool check(int j,string p){\n for(;j<p.length();j++) if(p[j]!='*') return false;\n... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "#define ll long long \nstring s1,s2 ;\nll n,m ; \nll dp[2020][2020] ; \n\nll rec(ll i,ll j){\n if(i==n){\n if(j==m){\n return 1 ; \n }\n ll cnt= 0 ; \n for(int x = j;x<m;x++){\n if(s2[x]!='*'){\n cnt++ ; \n break ; \n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "#define MAX 3000\nclass Solution {\npublic:\n bool func(int i,int j,string &s,string &p,int dp[MAX][MAX]){\n if(i<0)return j<0;\n if(j<0){\n for(int l=0;l<=i;l++){\n if(p[l]!='*')return false;\n }return true;\n }\n if(dp[i][j]!=-1)return d... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\n\npublic:\n bool isMatch(string s, string p) {\n vector <bitset <2001>> dp(s.size() + 1);\n dp[0][0] = 1;\n\n for (int j = 0; j < p.size(); j++) {\n if (p[j] != '*') break;\n dp[0][j + 1] = 1;\n }\n\n for (int j = 0; j < p.size()... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "#pragma GCC optimize(\"O2,O3,unroll-loops\")\n\nclass Solution {\n\npublic:\n bool isMatch(string s, string p) {\n vector <bitset <2001>> dp(s.size() + 1);\n dp[0][0] = 1;\n\n for (int j = 0; j < p.size(); j++) {\n if (p[j] != '*') break;\n dp[0][j + 1] = 1;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\n std::vector<std::vector<short>> dp;\n\npublic:\n bool isMatch(std::string s, std::string p) {\n dp = std::vector<std::vector<short>>(s.size(),\n std::vector<short>(p.size(), -1));\n return fn(s, p, 0, 0);\n }\n bool fn(std::string_view co... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool solve(vector<vector<optional<bool>>> &memo, const string& s, const string& p, int i , int j) {\n int n = s.size();\n int m = p.size();\n \n if (i == n && j == m) {\n return true;\n }\n if (i > n || j == m) {\n r... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int n = s.size(), m = p.size(); \n vector<vector<short>> memo(n, vector<short>(m, -1));\n return dp(s, p, n-1, m-1, memo);\n }\n\nprivate:\n bool dp(string& s, string& p, int i, int j, vector<vector<short>>& memo... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\nprivate:\n short int solve(string& a, string& b, vector<vector<short int>>&dp, int i, int j) {\n // if(i == 0 && j == 0) return 1;\n // if(j == 0 && i > 0) return 0;\n\n if(j == 0) return i == 0;\n\n if(i == 0 && j > 0) { // true if all remaining b[0...j] ar... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n bool isEqual(char a, char b) { return b == '?' || a == b; }\n bool helper(string& s, string& p, int i, int j, vector<vector<short>>& dp) {\n if (i == s.length() && j == p.length())\n return true;\n if (j == p.length())\n return false;\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\n uint64_t make_pair(const char* a, const char* b) {\n return uint64_t(a) xor (uint64_t(b) << 32);\n }\n\n std::unordered_set<uint64_t> parsed;\n bool hasOnlyG(const char* p) {\n while (*p == '*') {\n ++p;\n }\n return *p == '\\0';\n }\... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "int dp[2005][2005];\nclass Solution {\nprivate:\n bool f(string& p, string& s, int i, int j) {\n if (i < 0 && j < 0)\n return true;\n if (i < 0 && j >= 0)\n return false;\n if (j < 0 && i >= 0) {\n for (int k = 0; k <= i; ++k)\n if (p[... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "int dp[2000][2000];\nbool f(string& s,string& p,int i,int j)\n{\n int n=s.size(),m=p.size();\n if (i==n){\n if (j==m) return true;\n else{\n if (p[j]=='*') return f(s,p,i,j+1); \n return false;\n }\n }\n if (j==m) return false;\n if (dp[i][j]!=-1) r... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "namespace {\n\nint dp[2000][2000];\n\nint is_match_recursive(const string &s, const string &p, int i, int j) {\n if (dp[i][j] != -1) {\n return dp[i][j];\n }\n if (i == s.size() && j == p.size()) {\n return 1;\n } else if (p[j] == '*') {\n for (int k = i; k <= s.size(); ++k) {\n if (is_ma... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n\ntemplate<class Fun> class y_combinator_result { Fun fun_;\npublic:\n template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}\n template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*t... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "int dp[2001][2001];\nstring s ,t;\n\nclass Solution {\nprivate:\n bool match(int i , int j ){\n\n if(j==t.size() && i==s.size()) return true;\n if(j==t.size()) return false;\n if(i==s.size() && t[j]!='*') return false;\n if(dp[i][j]!=-1) return dp[i][j];\n if(i==s.size... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\nprivate:\n vector<int> cache;\n\n bool __isMatch(string& s, string& p, string::iterator sidx, string::iterator pidx) {\n for (; pidx != end(p); pidx++) {\n if (*pidx == '*') {\n for (;;) {\n ++pidx;\n if (pidx ==... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\nprivate:\n vector<int> cache;\n\n bool __isMatch(string& s, string& p, string::iterator sidx, string::iterator pidx) {\n for (; pidx != end(p); pidx++) {\n if (*pidx == '*') {\n for (;;) {\n ++pidx;\n if (pidx ==... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n int dp[2000][2000] = {0};\n bool helper(const string& s, const string& p, int left, int right) {\n int i = left;\n\n if(dp[left][right] == 1) return false;\n if(dp[left][right] == 2) return true;\n\n for (int j = right; j < p.size(); ++j) {\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\nprivate:\n vector<int> cache;\n\n bool __isMatch(string& s, string& p, string::iterator sidx, string::iterator pidx) {\n for (; pidx != end(p); pidx++) {\n if (*pidx == '*') {\n for (;;) {\n ++pidx;\n if (pidx ==... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\nprivate:\n vector<int> cache;\n\n bool __isMatch(string& s, string& p, string::iterator sidx, string::iterator pidx) {\n for (; pidx != end(p); pidx++) {\n if (*pidx == '*') {\n for (;;) {\n ++pidx;\n if (pidx ==... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n int dp[2001][2001];\n bool helper(string s, int ind1, string p, int ind2){\n if(ind1 < 0 && ind2 < 0) return true;\n if(ind2 < 0 && ind1 >=0) return false;\n\n if(ind1 < 0 && ind2 >=0){\n for(int k=0;k<=ind2;k++){\n if(p[k] !=... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n int dp[2001][2001];\n bool fun(int i,int j,string&s,string& p){\n if(j==p.length()&&i==s.length()) return true;\n else if(i==s.length()){\n for(int k=j;k<p.length();k++){\n if(p[k]!='*') return false;\n }\n retu... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\nint dp[2001][2001];\n bool match(string& s, string& p, int i, int j) {\n\n if (i == 0 and j == 0)\n return true;\n if (i > 0 and j == 0)\n return false;\n\n if (i == 0 and j > 0) {\n for (int k = 1; k <= j; k++) {\n ... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 1 | {
"code": "class Solution {\npublic:\n int dp[2001][2001]; \n bool solve(string &s,string &p,int idx1,int idx2){\n if(idx1 == s.length() && idx2 == p.length()){\n return true;\n }\n if(dp[idx1][idx2] != -1){\n return dp[idx1][idx2];\n }\n if(idx1 == s.... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution {\npublic:\n string s1,s2;\n int m,n;\n int dp[2001][2001];\n int fn(int i,int j){\n if(i>=m && j>=n) return 1;\n if(i>=m){\n for(int k=j;k<n;k++) if(s2[k]!='*') return 0;\n return 1;\n }\n if(j>=n){\n for(int k=i;k<m;k... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution {\npublic:\n string s1,s2;\n int m,n;\n int dp[2001][2001];\n int fn(int i,int j){\n if(i>=m && j>=n) return 1;\n if(i>=m){\n for(int k=j;k<n;k++) if(s2[k]!='*') return 0;\n return 1;\n }\n if(j>=n){\n for(int k=i;k<m;k... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n int n, m, f[2005][2005], g[2005];\n //f[i][j]:the first i from s and first j from p is it matchable?\n //g[j]: is there any i for which f[i][j] is true\n memset(f, 0, sizeof f);\n memset(g, 0, sizeof g);\... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution \n{\npublic:\n bool isMatch(string s, string p) \n {\n int m = s.size(), n = p.size();\n std::memset(dp_, 0, sizeof(dp_));\n\n s = \"#\" + s;\n p = \"#\" + p;\n\n dp_[0][0] = 1;\n for (int j = 1; j <= n; ++j)\n {\n if (p[j] !=... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution {\npublic:\n string cleanup(string p) {\n string cleaned_str = \"\";\n for (int i = 0; i < p.size(); i++) {\n if (cleaned_str.empty() || p[i] != '*') {\n cleaned_str.append(1, p[i]);\n } else if (i >= 1 && cleaned_str[cleaned_str.size() -... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution {\npublic:\nint dp[2002][2002];\n bool f(int i,int j,string &s,string &p, unordered_map<int,int>&mp){\n if(i==s.size() && j==p.size()) return true;\n if(j==p.size()) return false;\n if(i==s.size()){\n if(mp.count(j)) return true;\n return false;\n }\n if(dp[i][j... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution {\npublic:\nint dp[2002][2002];\n bool f(int i,int j,string &s,string &p, unordered_map<int,int>&mp){\n if(i==s.size() && j==p.size()) return true;\n if(j==p.size()) return false;\n if(i==s.size()){\n if(mp.count(j)) return true;\n return false;\n }\n if(dp[i][j... |
44 | <p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'?'</code> Matches any single character.</li>
<li><code>'*'</code> Matches any sequence of cha... | 2 | {
"code": "class Solution \n{\n public:\n bool isMatch(string s, string p) \n {\n int n = s.size() , m = p.size();\n\n int dp[2001][2001];\n // dp[i][j] - is it possible to match s(i..n) with p(j..m)\n memset( dp , -1 , sizeof(dp) );\n\n function<int(int,int)> f =[&]( int i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.