#K82092. Pattern Matching with Wildcards
Pattern Matching with Wildcards
Pattern Matching with Wildcards
Given a string and a pattern, determine if the entire string matches the pattern exactly. The pattern may contain the wildcard character ?
, which can match any single character. In other words, for every position i, either the pattern has a ?
or its character is identical to the corresponding character in the string. Note that the match is case-sensitive and the string and pattern must have the same length.
Input: Two lines of input where the first line is the string and the second line is the pattern.
Output: Output True
if the pattern matches the string exactly, otherwise output False
.
inputFormat
The input consists of two lines read from standard input (stdin):
- The first line is the string s (consisting of lowercase letters).
- The second line is the pattern, which is of the same expected length as s and may include the wildcard character
?
.
outputFormat
Print True
if the pattern matches the string exactly, else print False
to the standard output (stdout).
abcdef
a?cde?
True
</p>