Codey and Manuscript
https://www.hackerrank.com/contests/codenection-2024-preliminary-round-open-category/challenges/cn24-7/problem
Question
Codey, a scholar from the kingdom of CodeNection, has been given an important mission by Queen Zoey. Queen Zoey recently uncovered an ancient manuscript that holds a string s, believed to contain a hidden message about the future king of the kingdom. However, parts of the manuscript are missing, with these gaps marked by * where letters once were.
To help restore the message, Queen Zoey gives Codey another string v, which is known to be part of the hidden message. Codey’s task is to determine whether it is possible to fill the gaps in s with lowercase English letters such that v appears as a subsequence of the s.
Codey must report back to Queen Zoey about his progress.
A string b is subsequence of string a if it's possible to remove some character in a to get b(without changing the order).
Input Format
The first line contains a single integer t, where t represents the number of test cases.
The first line of each test case contains a single string s, where s represents the damaged manuscript. It contains lowercase English letters and *.
The second line of each test case contains a single string v, where v represents the hidden message that must appear as a subsequence in the completed manuscript.
Constraints
It is guaranteed that the sum of across all test cases doesn't exceed .
Output Format
For each test case, if it’s possible to fulfill the conditions, output YES. Otherwise, output NO.
Sample Inputs:
Input
3
co**y
codey
ma**a
leo
z**y
oOutput
YES
NO
YESExplanation
In the first test case, the missing characters * can be replaced with d and e to form codey.
In the second test case, it's impossible to fill in the gaps to form leo.
In the third test case, one of the missing character * can be replaced with o.
Last updated