Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- js
- suspense ๋ณ๋ชฉํ์
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- next13 emotion
- ๋ฐฑ์ค 2108 nodejs
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- emotion RSC
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- ๊ตฌ๋ฆํค
- js ์ค์ฝํ
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- suspense ๋์์๋ฆฌ
- ์ค์ฝํ
- ์ต์ ๋์ฒด์ด๋
- app router emotion
- ๋ฐฑ์ค 1339๋ฒ js
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- ์นด์นด์ค ์ฝํ
- suspense react-query
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- emtion app router
- js ๋ฌธ์์ด ์์ถ
- suspense ๋น๋๊ธฐ
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ์ฌ์ฉ์ฑ ๊ฐ์
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
Archives
- Today
- Total
Lennon FE
[๋ฐฑ์ค 9012๋ฒ] ๊ดํธ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
๐ฅ Algorithm/Baekjoon
[๋ฐฑ์ค 9012๋ฒ] ๊ดํธ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon 2022. 1. 20. 17:09728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/9012
const fs = require('fs');
let input = fs.readFileSync('dev/stdin').toString().trim().split('\n');
input.shift();
const answer = [];
input.filter((value) => {
let isVPSCount = 0;
for (let i = 0; i < value.length; i++) {
if (value[i] === '(') {
isVPSCount++;
} else {
isVPSCount--;
}
if (isVPSCount < 0) {
answer.push('NO');
break;
}
}
if (isVPSCount === 0) {
answer.push('YES');
} else if (isVPSCount > 0) {
answer.push('NO');
}
});
console.log(answer.join('\n'));
๊ท ํ์กํ ๊ดํธ๋ผ๋ฉด
'(' ๋ก ์์ํด์ผํ๋ฉฐ, '(' ์ผ๋ ๊ฐ์ ๋ํด +1 ํด์ฃผ๋ฉฐ, ')'์ผ ๋ -1 ํด์ค๋ค๊ณ ๊ฐ์ ํ์ ๋ ๋ก์ง ์งํ ๋์ค ์์๊ฐ ๋์ค๋ฉด ์๋๋ค.
ex) ()) => -1์ด ๊ฒฐ๊ณผ๊ฐ์ด๋ฏ๋ก ๋ฌด์กฐ๊ฑด ๊ท ํ์ด ๊นจ์ง๊ฒ ๋๋ค.
์ฆ ์์๊ฐ ๋์ค๋ฉด ๋ฐ๋ก ๊ฐ์ answer๋ฐฐ์ด์ ๋ฃ์ด์ฃผ๊ณ break๋ฅผ ๊ฑธ์ด์ค๋ค.
๊ทธ ํ ๋ฐ์ isVPSCount ๊ฐ 0์ด๋ฉด VPS์ด๊ณ , 0๋ณด๋ค ํฌ๋ฉด VPS๊ฐ ์๋๋ฏ๋ก answer์ pushํด์ฃผ๋ฉด ๋๋ค.
์ถ๋ ฅ๊ฐ์ ๋ํ ๋๋ฌธ์, ์๋ฌธ์๋ฅผ ์ ํ์ธํ์!
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 4949๋ฒ] ๊ท ํ์กํ ์ธ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.01.20 |
---|---|
๋ฐฑ์ค nodejs ์ ๋ ฅํ๋ ๋ฐฉ๋ฒ / ๋ฐฑ์ค ์๋ฐ์คํฌ๋ฆฝํธ ์ ๋ ฅ (0) | 2022.01.20 |
[๋ฐฑ์ค 10773๋ฒ] ์ ๋ก - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.01.20 |
[๋ฐฑ์ค 10828๋ฒ] ์คํ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.01.20 |
[๋ฐฑ์ค 18870๋ฒ] ์ขํ ์์ถ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.01.19 |
Comments