#C1547. Reverse a String Using a Stack

    ID: 44764 Type: Default 1000ms 256MiB

Reverse a String Using a Stack

Reverse a String Using a Stack

You are given a string S. Your task is to reverse the string by simulating a stack operation. Specifically, push each character of the string onto a stack, and then pop all characters to form the reversed string.

The reversal must be performed using the stack data structure. This means that the last character pushed should be the first one in the output, following the Last In First Out (LIFO) principle.

Note: Ensure that your program reads input from standard input (stdin) and writes the result to standard output (stdout).

inputFormat

A single line string S is provided as input from stdin. The string may contain alphanumeric characters and symbols.

outputFormat

The output should be the reversed version of the input string, constructed using a stack. The result should be printed to stdout.## sample

hello
olleh