150. Reverse a String With a Stack
Foundation1000 ms256 MBSolved by 0%
Read one line and print it reversed, using a stack.
Push every character, then pop them all, last in, first out gives you the reverse for free. That is the point of the exercise.
Constraints - The line has between 1 and 100000 characters. - Printable ASCII only.
Input
A single line of text.
Output
Print the line with its characters in reverse order.
Inputhello
Outputolleh
Noteis a single word
Inputhello world
Outputdlrow olleh
Notecontains a space, so reading only the first word gives the wrong answer
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.