Decide whether each uppercase string is a Slurpy, meaning a Slimp immediately followed by a Slump, where both are defined by recursive grammar rules.
Medium5RecursionStringImplementationBacktrackingInterviewNo attempts yetTime limit2sMemory limit512 MBA Slurpy is a string that satisfies the rules defined below. Write a program that reads strings and decides whether each one is a Slurpy.
First, a Slump is a string that satisfies these rules.
A Slimp is a string that satisfies these rules.
A Slurpy is one Slimp followed by one Slump.
The classification works out like this.
The first line holds the number of strings N, a positive integer no larger than 10. Each of the next N lines holds one string. Every string has length at most 60 and consists of uppercase letters only.
Print SLURPYS OUTPUT on the first line. Then, in input order, print one line per string: YES if the string is a Slurpy, NO if it is not. Print END OF OUTPUT on the last line.