Skip to content

Commit abdee81

Browse files
committed
docs: 오타 및 잘못된 예제 수정
1 parent ea222b7 commit abdee81

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

contents/posts/ProblemSolving/baekjoon-tip-for-nodejs.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let input = fs
4343

4444
```javascript
4545
let input = fs
46-
.readFileSync(process.platform === "linux" ? "/dev/stdin" : 0)
46+
.readFileSync(process.platform === "linux" ? 0 : "./in.txt")
4747
.toString()
4848
.trim()
4949
.split(/\s+/); // 개행문자와 공백문자 모두를 기준으로 분리
@@ -220,6 +220,7 @@ class Queue {
220220
this.q[this.tail++] = v;
221221
}
222222
pop() {
223+
if (this.isEmpty()) return null;
223224
const v = this.q[this.head];
224225
delete this.q[this.head++];
225226
return v;
@@ -255,11 +256,13 @@ class Deque {
255256
this.dq[this.tail++] = v;
256257
}
257258
popFront() {
259+
if (this.isEmpty()) return null;
258260
const v = this.dq[this.head];
259261
delete this.dq[this.head++];
260262
return v;
261263
}
262264
popBack() {
265+
if (this.isEmpty()) return null;
263266
const v = this.dq[--this.tail];
264267
delete this.dq[this.tail];
265268
return v;
@@ -303,7 +306,7 @@ class MaxHeap {
303306
}
304307
}
305308
pop() {
306-
if (this.heap.length === 1) return 0;
309+
if (this.heap.length === 1) return null;
307310
if (this.heap.length === 2) return this.heap.pop();
308311

309312
const element = this.heap[1];
@@ -625,7 +628,7 @@ const char = String.fromCharCode(65); // 'A'
625628

626629
'A' 는 65, 'a' 는 97, '0' 은 48 의 아스키코드 값을 가집니다.
627630

628-
문자의 범위를 비교할때 `/\/[A-Z]/` 같은 정규표현식 대신 아스키코드 값을 비교하는 방법이 더 빠릅니다.
631+
문자의 범위를 비교할때 `/[A-Z]/` 같은 정규표현식 대신 아스키코드 값을 비교하는 방법이 더 빠릅니다.
629632

630633
```javascript
631634
const A = "A".charCodeAt(0);
@@ -772,6 +775,6 @@ mask |= 1n << 40n;
772775

773776
<br><br><br><br>
774777

775-
UnionFind, SegmentTree, Trie 와 같은 고급 자료구조들은 따로 다루지 않았습니다. <br/>
778+
UnionFind, SegmentTree, Trie 와 같은 고급 자료구조나 직접적인 알고리즘들은 따로 다루지 않았습니다. <br/>
776779
다른 팁들이 생기면 계속 추가할 예정입니다. 😊 <br/>
777780
추가하면 좋을 내용이 있다면 댓글로 알려주세요 🙌

0 commit comments

Comments
 (0)