JDCC '17 Contest 3 S1 - <<<<3<33<333
View as PDFVedant really wants the recruiters at a certain internet search company to know how much he wants to work there, so he adds a bunch of cute hearts at the end of his resume.
A cute heart is defined as one of the following:
<3is a cute heart<x3, wherexis a cute heartxy, wherexandyare cute hearts
For example, <<<333, <<3<33, <3<3 and <<<<3<33<333 are all cute hearts, but <<3,
<33< and 3<3< are not cute hearts.
Help Vedant figure out whether the text he added to his resume is a cute heart!
Input
The input is a single string with no more than characters, with each character being
either
< or 3.
Output
Output <3 if the text is a cute heart, and </3 otherwise.
Sample Input 1
<<<33<33
Sample Output 1
<3
Explanation for Sample Input 1
All the hearts are nested correctly within each other.
Sample Input 2
<3<<<3333
Sample Output 2
</3
Explanation for Sample Input 2
The last character, 3, is not matched with a <, so it can't be a cute heart.
Comments