Challenge 2: Reverse a Stack
Given a stack, reverse the contents of the stack.
We'll cover the following...
Problem Statement
Implement a function that takes a stack, testVariable
, and reverses it. Do not use any other extra stack or data structure.
Helper Stack
class is provided in the file stack.js
. Take a look at the file before implementing your solution. If you want to study stacks in detail, review Interview Refresher Course on Data Structures in Javascript.
Write your code in the space provided in the file
index.js
.
Input
A variable testVariable
that contains a stack.
Output
No explicit output. Our task is to reverse the contents of the stack.
Sample Input
8, 5, 3, 2
Access this course and 1400+ top-rated courses and projects.