#C1539. Taco: String Matching with Dot Operator

    ID: 44755 Type: Default 1000ms 256MiB

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" and p = "ab.d" should return True.
  • Input: s = "hello" and p = "h.e.o" should return False.

inputFormat

The input consists of two lines:

  1. The first line contains the string s.
  2. 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.

## sample
abcd
ab.d
True