💡JavaScript Levenshtein & Recursion Solution
The Idea - Levenshtein Distance Algorithm (Edit Distance)\n1. Apply lavenshtein distance algorithm. More here.\n2. Build a matrix where each cell represents whe
#### The Idea - Levenshtein Distance Algorithm (Edit Distance)\n1. Apply lavenshtein distance algorithm. More [here](https://leetcode.com/problems/edit-distance/discuss/428527/JavaScript-Solution).\n2. Build a matrix where each cell represents whether the string and input are matching, up to the current position\n3. For every cell, it\'s trying to be the best matching possible, meaning it\'s trying to hit a `true`, we have 3 conditions, if the patten is `*`, then we can either look up or left, if the two characters are the same or patten is `?`, then we inherit the result from previous `dp[i-1][j-1]`, other wise, it is a `false`.\n```\nvar isMatch = function(s, p) {\n    let dp = Array(s.length+1).fill(null).map(()=>Array(p.length+1).fill(false));\n    dp[0][0] = true;\n\n    // initialize first column (string)\n    for (let i=1;i<=s.length;i++) {\n        dp[i][0] = false;\n    }\n\n    // initialize first row (pattern) \n    for (let i=1;i<=p.length;i++) {\n        dp[0][i] = dp[0][i-1] && p[i-1] == "*";\n    }\n    \n    for (let i=1;i<=s.length;i++) {\n        for (let j=1;j<=p.length;j++) {\n            if (p[j-1]==\'*\') {\n                dp[i][j] = dp[i-1][j] || dp[i][j-1]; // look top or left\n            } else if (s[i-1] == p[j-1] || p[j-1]==\'?\') {\n                dp[i][j] = dp[i-1][j-1]; // inherit from previous result\n            }\n        }\n    }\n    return dp[s.length][p.length]\n}\n```\n\n#### The Idea - Recursion\n1. If two strings are equal (`s==p`), or only `*` left in pattern, it\'s `true`\n2. If only one of the string is empty, it\'s `false`\n3. If two characters are the same (`p[0]==s[0]`) or pattern is `?`, recursivly check the rest\n4. if see a `*`, we can remove 1 character or we can remove 0 character and move to the next pattern.\n``` javascript\nvar isMatchRecursion = function(s, p) {\n    let dp = {};\n\n    var recur = function(s, p) {\n        if (!dp[s]) dp[s] = {};\n        if (dp[s][p]!=null) return dp[s][p];\n\n        if ( s == p || (p.includes(\'*\') && !p.replace(/\\*/g, \'\'))) {\n            dp[s][p] = true;\n        } else if (s.length == 0 || p.length == 0) {\n            dp[s][p] = false;\n        } else if (p[0] == \'?\' || p[0] == s[0]) {\n            dp[s][p] = recur(s.slice(1), p.slice(1));\n        } else if (p[0] == \'*\') {\n            dp[s][p] = recur(s.slice(1), p) || recur(s, p.slice(1));\n        } else {\n            dp[s][p] = false;\n        }\n\n        return dp[s][p];\n    }\n\n    return recur(s, p);\n};\n```
['JavaScript']