- Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
71 lines (63 loc) · 1.39 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* # 44. Wildcard Matching
*
Given an input string `(s)` and a pattern `(p)`, implement wildcard pattern matching with support for `'?'` and `'*'`.
```bash
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
```
The matching should cover the entire input string (not partial).
Note:
- `s` could be empty and contains only lowercase letters `a-z`.
- `p` could be empty and contains only lowercase letters `a-z`, and characters like `?` or `*`.
## Example
```bash
Input:
s = "aa"
p = "a"
Output: false
Explanation: "a" does not match the entire string "aa".
```
```bash
Input:
s = "aa"
p = "*"
Output: true
Explanation: '*' matches any sequence.
```
```bash
Input:
s = "cb"
p = "?a"
Output: false
Explanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.
```
```bash
Input:
s = "adceb"
p = "*a*b"
Output: true
Explanation: The first '*' matches the empty sequence, while the second '*' matches the substring "dce".
```
```bash
Input:
s = "acdcb"
p = "a*c?b"
Output: false
```
*/
exporttypeSolution=(s: string,p: string)=>boolean;
/**
* @date
* @time
* @space
* @memory {leetcode.com}
* @time {leetcode.com}
* @memory {leetcode-cn.com}
* @time {leetcode-cn.com}
*/
exportconstisMatch=(s: string,p: string): boolean=>{
constpp: string[]=["a","*","?","b"];
returnpp!==[];
};
isMatch("acdcb","");