알고리즘
검색결과
1
개
js로 스택/큐 구현하기
인트로 집중이 안돼서 오랜만에 알고리즘 복습하는 시간이나 가져보았습니다. 클래스로 스택 구현 class Stack { constructor() { this.stackArr = []; this.top = 0; } push(value) { this.stackArr[this.top] = value; this.top += 1; return value; } pop() { if(this.top === 0) { console.log('배열이 비었습니다'); return null; } this.top -= 1; return this.stackArr.pop(); } getsize() { return this.stackArr.length; } } const stack = new Stack; stack.push(1); st..
알고리즘
2023. 6. 12. 15:11