Given a stack of integers st , write a program to reverse the stack using recursion .

Problem Note

  • You are not allowed to use loop constructs like while, for..etc, Return st after reversing it using recursion. It is mandatory to reverse st using recursion.

Example 1

Input: st = [1, 5, 3, 2, 4]
Output:[4, 2, 3, 5, 1]
Explanation: After reversing the stack [1, 5, 3, 2, 4] becomes [4, 2, 3, 5, 1].

Example 2

Input: st = [5, 17, 100, 11]
Output: [11, 100, 17, 5]
Explanation: After reversing the stack [5, 17, 100, 11] becomes [11, 100, 17, 5]