deno.land / x / masx200_leetcode_test@10.6.5 / regular-expression-matching / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export default function isMatch(s: string, p: string): boolean { //console.log([s, p]); if (p === ".*") return true; if (p.length === 0) return s.length === 0; const first_match = !!s.length && (s[0] === p[0] || p[0] === "."); if (p.length >= 2 && p[1] == "*") { return ( (first_match && isMatch(s.slice(1), p)) || isMatch(s, p.slice(2)) ); } else { return first_match && isMatch(s.slice(1), p.slice(1)); }}
masx200_leetcode_test

Version Info

Tagged at
a year ago