Given a stack of integers A. You are required to reverse the stack using recursion.
You are not allowed to use loop constructs like while, for..etc,
Return A after reversing it using recursion.
NOTE: It is mandatory to reverse A using recursion.
The only argument given is the integer array A.
Return the reversal of A using stack.
1 <= length of the array <= 2000 1 <= A[i] <= 10^8
Input 1: A = [1, 5, 3, 2, 4] Output 1: [4, 2, 3, 5, 1] Input 2: A = [5, 17, 100, 11] Output 2: [11, 100, 17, 5]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.