Skip to content

Commit 2978573

Browse files
[BOJ] 14646 욱제는 결정장애야!! (S5)
1 parent 1ab05ea commit 2978573

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

서정우/9주차/260223.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require("fs");
2+
const filePath = process.platform === "linux" ? "/dev/stdin" : "./서정우/input.txt";
3+
const input = fs
4+
.readFileSync(filePath)
5+
.toString()
6+
.trim()
7+
.split("\n")
8+
.map((el) => el.trim());
9+
10+
const N = Number(input[0]);
11+
const nums = input[1].split(" ").map(Number);
12+
13+
let maxCount = 0;
14+
let count = 0;
15+
const arr = Array(N + 1).fill(0);
16+
for (let i = 0; i < nums.length; i++) {
17+
const num = nums[i];
18+
if (arr[num]) {
19+
arr[num] = 0;
20+
count--;
21+
} else {
22+
arr[num] = 1;
23+
count++;
24+
}
25+
maxCount = Math.max(maxCount, count);
26+
}
27+
console.log(maxCount);

서정우/input.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
9788968322*73
1+
5
2+
1 1 2 2 3 3 4 4 5 5

0 commit comments

Comments
 (0)