<code />
class Stack {
constructor () {
this.stack = [];
this.size = 0;
}
push(arg) {
this.size++;
this.stack = this.stack.concat(arg);
}
size() {
return this.size;
}
pop() {
if (this.stack.length === 0) {
return -1
}
const popNum = this.stack[this.size - 1];
this.stack = this.stack.slice(0, -1);
this.size--
return popNum;
}
empty() {
if (this.size === 0) {
return 1;
}
else {
return 0;
}
}
top() {
if (this.size === 0) {
return -1;
}
else {
return this.stack[this.size - 1];
}
}
};
1. 백준에서 nodejs는 입출력 구현 하는게 더 어려운거 같다.
반응형
'BOJ' 카테고리의 다른 글
[Algorithm] 올림피아드 최대점수구하기 python (0) | 2022.04.05 |
---|---|
[Node.js] 백준 #10828 스택 (실패 : 시간초과) (0) | 2021.07.20 |
Baekjoon #2292번 벌집 [Python] (0) | 2020.10.06 |
Baekjoon #2839번 설탕배달 [Python] (0) | 2020.10.06 |
baekjoon #1712번 손익분기점 [Python] (0) | 2020.10.06 |