#K44917. Wildcard Subsequence Checker

    ID: 27638 Type: Default 1000ms 256MiB

Wildcard Subsequence Checker

Wildcard Subsequence Checker

You are given two strings: a text string and a pattern string. The pattern string may include the wildcard character ? which can match any single character. Your task is to determine whether the pattern (interpreting ? as a wildcard) is a subsequence of the text.

A subsequence is a sequence that can be derived from the text by deleting some (or no) characters without changing the order of the remaining characters. For example, "p?o??" is a subsequence of "programming" because each character in the pattern, including wildcards, can be matched in order in the text.

Formally, let \( T \) be the text and \( P \) be the pattern of length \( m \). We want to check if there exists indices \( 1 \leq i_1 < i_2 < \cdots < i_m \leq n \) (where \( n \) is the length of \( T \)) such that for each \( k = 1, 2, \ldots, m \), \( P_k = T_{i_k} \) or \( P_k = \textit{?} \).

If the pattern is a subsequence, output Yes; otherwise, output No.

inputFormat

The input consists of two lines. The first line contains the text string. The second line contains the pattern string which may include the wildcard character '?' that can match any single character.

outputFormat

Output a single line containing 'Yes' if the pattern is a subsequence of the text (with '?' acting as wildcards), otherwise output 'No'.## sample

programming
programming
Yes