Skip to content
CampusEduX

Reverse a Stack

Easyjavapythonccppjavascript

Given a stack of integers described from bottom to top, print the stack contents after reversing it, again from bottom to top.

Input Format

The first line contains an integer N. The second line contains N space-separated integers, the stack from bottom to top.

Output Format

Print the reversed stack from bottom to top, separated by single spaces.

Related Problems

  • Implement Stack
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Implement Queue
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Balanced Parentheses
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...