Problem:
Shikhi just learned typing. She still types many unnecessary alphabets.
She wants to type "namaste", but end up typing sting str. Print "YES" if "namaste" can be obtained by deleting some alphabets from string str, else print "NO". Example, "YES" for "asnamastiie", "NO" for "namteass"
She wants to type "namaste", but end up typing sting str. Print "YES" if "namaste" can be obtained by deleting some alphabets from string str, else print "NO". Example, "YES" for "asnamastiie", "NO" for "namteass"
Input Format:
String str
Output Format:
YES/NOConstraints:
NoneSample Input
aeiounqwsamqwsdaiutstqqwwseqjal
Sample Output:
YESExplanations:
Red color for namaste- aeiounqwsamqwsdaiutstqqwwseqjal
Solution:
if($str=~ /n.*a.*m.*a.*s.*t.*e.*/)
{
print "YES";
}
else
{
print "NO";
}
Tips:
Simple regex use case
No comments:
Post a Comment