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.
Example 1
Input
4 1 2 3 4
Output
4 3 2 1
Explanation: The bottom element becomes the top after reversal.
- 1 <= N <= 10000
- -1000000000 <= value <= 1000000000