In 1D stack, I can implement this code below
// Create 1D stack
var stack = new Array(1000)
stack.push(23)
stack.pop()
But for the 2D stack and multi-dimensional stack, how to implement this stack which can do the push and pop function?
In 1D stack, I can implement this code below
// Create 1D stack
var stack = new Array(1000)
stack.push(23)
stack.pop()
But for the 2D stack and multi-dimensional stack, how to implement this stack which can do the push and pop function?
Here is the example to create 2D stack,
var s = new Array(100);
for( let i=0;i<100;i++) {
s[i] = [];
for( let j=0; j<100; j++) {
s[i][j] = i*j;
}
}
console.log(s);