Editorial for TLE '17 Contest 2 P1 - Cadadr
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
This problem is relatively simple and can be accomplished in several ways.
One way is to iterate through the input string and for each a
, output (car
and for each d
, output (cdr
.
After we go through the string, we output x
and all of the required )
. In particular, we need to output )
for each a
or d
in the original string. Additionally, make sure there is a space between the last car
or cdr
and x
.
Another method involves adding to an answer string and outputting the string at the end, but one must be cautious since in certain languages, adding strings takes
Time Complexity:
Comments