AlgoUniversity
  • Go Back
Discussion
Wildcard Matching :

Author

Gigaliths

Difficulty Level : Medium

Submissions : 340

Asked In : Samsung

Marks :10

: 2 | : 0

Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:

'?' Matches any single character.

'*' Matches any sequence of characters. ( zero or more )

The matching should cover the entire input string.

Input

First line contains a single string corresponding to 's'.

Second line contains a single string corresponding to 'p'.

Constraints

$$$ 1 \le |s| \le 2000 $$$

$$$ 1 \le |p| \le 2000 $$$

Output

Print either "YES" or "NO"

Examples

Input
cb
?a
Output
NO
Input
abzzzc
a*b*c
Output
YES

Note

Input 1

'?' matches 'c', but the second letter is 'a', which does not match 'b'.

Input 2

The pattern matches perfectly where *1 = " and *2 = 'zzz'

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.