Code Plagiarism
InterviewTime limit1sMemory limit1024 MB
Given strings s and t, decide whether t can remain after repeatedly deleting any two adjacent characters from s.
- Level
Medium5 of 10
- Topics
- Greedy, Two pointers, String
- Solved
- No attempts yet
Statement
Alice and Bob are employees of the same well-known company. Each of them proposed a fix for a critical bug to their team lead. Alice suspects that Bob took her code and added characters that do not change its behavior, so that he would look like he worked harder. The company writes code in an esoteric programming language, and each solution is a single line of lowercase Latin letters. Alice's code is the string , and Bob's code is the string .
Bob's keyboard is broken, so he can type exactly two characters at a time. The two characters do not have to be the same, and he can insert them at any position in the string. The team lead wants to check whether can be obtained from by repeatedly cutting out two adjacent characters. Determine whether can be obtained from by cutting out two adjacent characters any number of times.
Input
The first line contains the string of lowercase Latin letters (). The second line contains the string of lowercase Latin letters ().
Output
Print YES if can be obtained from by cutting out two adjacent characters any number of times. Otherwise, print NO.