-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBOJ_Vps.js
46 lines (41 loc) · 1.06 KB
/
BOJ_Vps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @desc site : Baekjoon Onlie Judge
* @desc level: S4
* @desc url : https://www.acmicpc.net/problem/9012
*/
const fs = require("fs");
const { off } = require("process");
const input = fs.readFileSync("/dev/stdin").toString().trim().split("\n");
const inputCount = input.length;
let buffer = [];
const open = "(";
const close = ")";
for (let index = 1; index < inputCount; index++) {
buffer = input[index].split("");
if (validationSameCount()) {
console.log("YES");
} else {
console.log("NO");
}
}
function validationSameCount(data) {
let validateFlag = true;
const status = [];
if (buffer[0] === close) {
validateFlag = false;
} else {
buffer.forEach((item, index) => {
if (item == open) {
status.push(item);
} else if (status.length && item == close) {
status.pop();
} else {
validateFlag = false;
}
});
}
if (status.length) {
validateFlag = false;
}
return validateFlag;
}