Skip to content

Commit 1de6145

Browse files
committed
Update comments
1 parent 593cef8 commit 1de6145

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

algorithms/implement-stack-using-queues.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ MyStack.prototype.push = function (x) {
1919
* @return {number}
2020
*/
2121
MyStack.prototype.pop = function () {
22-
// 将queue中除了最后一个元素之外的都copy到backup中
22+
// queue: [1, 2, 3, 4]
23+
// backup: []
24+
// =>
25+
// queue: [4]
26+
// backup: [1, 2, 3]
27+
// =>
28+
// queue: [4, 1, 2, 3]
29+
// bakcup: []
30+
31+
// 将 queue 中除了最后一个元素之外的都 copy 到 backup 中
2332
while (this.queue.length > 1) {
2433
this.backup.push(this.queue.shift());
2534
}

0 commit comments

Comments
 (0)