#C1539. Taco: String Matching with Dot Operator
Taco: String Matching with Dot Operator
Taco: String Matching with Dot Operator
You are given two strings s and p. The string p represents a pattern that may contain the special character .
. The dot character matches any single character. Your task is to determine if s exactly matches the pattern p under the following rule:
For every index \(i\), either p[i] is exactly equal to s[i] or p[i] is a dot (.
), which matches any single character. Formally, the match must satisfy:
[ \forall i, ; p[i] = s[i] \quad \text{or} \quad p[i] = . ]
Note that the lengths of s and p must be identical for a match to occur.
For example:
- Input:
s = "abcd"
andp = "ab.d"
should returnTrue
. - Input:
s = "hello"
andp = "h.e.o"
should returnFalse
.
inputFormat
The input consists of two lines:
- The first line contains the string
s
. - The second line contains the pattern
p
.
Both s
and p
are non-empty and of equal length.
outputFormat
Output a single line containing True
if the string s
matches the pattern p
according to the rules described, otherwise print False
.
abcd
ab.d
True