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
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution