255. Regular Expression Matching
HardDynamic Programming
. matches any character and x* matches zero or more of the preceding element. Print YES if the pattern matches the entire string, else NO.
Input format
Line 1: s Line 2: pattern
Output format
YES or NO
Example 1
Input
aa a
Output
NO
Example 2
Input
aa a*
Output
YES
Constraints
1 ≤ |s|, |p| ≤ 30
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…