Given a stack, reverse it using recursion. You are not allowed to use any extra space other than the internal stack space used by recursion.
{
"stack": [
1,
2,
3,
4,
5
]
}[
5,
4,
3,
2,
1
]{
"stack": [
3,
2,
1,
4
]
}[
4,
1,
2,
3
]{
"stack": [
1
]
}[
1
]Sign in to Run Code and Submit