Decide if scanning the message and skipping letters outside the remaining password set reproduces the password in order.
Easy2SimulationStringInterviewNo attempts yetTime limit1sMemory limit256 MBA company hides a password inside a longer string of uppercase letters. That string is called a message, and a message is valid only when it stands in the following relation to the password.
Write the password as c1c2…cP. The characters need not be distinct. Scan the message from the beginning and look for the first character that belongs to the set {c1,…,cP}; that character must be c1. Continue from the position just after it and look for the first character that belongs to {c2,…,cP}; that character must be c2. The rule continues the same way through c3 and on to cP.
For example, take the password ABC. The message HAPPYBIRTHDAYCACEY is valid.
For the same password ABC, the message TRAGICBIRTHDAYCACEY is not valid. A is indeed the first character from {A,B,C} to appear, but after it the first character from {B,C} is C rather than B.
The message HAPPYBIRTHDAY is also not valid for ABC, because no C ever appears.
Repeated letters in the password follow the same rule. For the password SECRET, the message SOMECHORESARETOUGH is valid. The message SOMECHEERSARETOUGH is not valid, because an extra E turns up at the point where an R is expected.
One line holds two strings separated by a space. The first is the password, of length P with 3≤P≤8. The second is the message, of length S with 10≤S≤40. Both strings consist only of uppercase letters, so neither contains whitespace, lowercase letters, digits, or other special characters.
Print a single line. Print PASS if the second string is a valid message for the password, and FAIL otherwise.