-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueueStack.js
More file actions
47 lines (39 loc) · 984 Bytes
/
queueStack.js
File metadata and controls
47 lines (39 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Write a stack using your preferred instantiation pattern.
* Avoid using native array methods i.e., push, pop, and length.
* Once you're done, implement a queue using two stacks.
*/
/**
* Stack Class
*/
var Stack = function() {
// add an item to the top of the stack
this.push = function(){
};
// remove an item from the top of the stack
this.pop = function(){
};
// return the number of items in the stack
this.size = function(){
};
};
/**
* Queue Class
*/
var Queue = function() {
// Use two `stack` instances to implement your `queue` Class
var inbox = new Stack();
var outbox = new Stack();
// called to add an item to the `queue`
this.enqueue = function(){
// TODO: implement `enqueue`
};
// called to remove an item from the `queue`
this.dequeue = function(){
// TODO: implement `dequeue`
};
// should return the number of items in the queue
this.size = function(){
// TODO: implement `size`
};
};