Skip to content

Commit 85e7262

Browse files
committed
feat(L-I): Stack
1 parent 5d6b89f commit 85e7262

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

L-I/0003 Stack ( L-I )/Stack.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Stack {
2+
constructor() {
3+
this.stack = []
4+
}
5+
6+
push(value) {
7+
this.stack.push(value)
8+
}
9+
10+
pop() {
11+
return this.stack.pop()
12+
}
13+
14+
peek() {
15+
return this.stack.at(-1)
16+
}
17+
18+
get size() {
19+
return this.stack.length
20+
}
21+
}
22+
23+
module.exports = Stack

0 commit comments

Comments
 (0)