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
- ์ค์ฝํ
- suspense ๋น๋๊ธฐ
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- js ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 2108 nodejs
- suspense ๋ณ๋ชฉํ์
- js
- ๋ฐฑ์ค 1339๋ฒ js
- next13 emotion
- ์ต์ ๋์ฒด์ด๋
- suspense react-query
- ์ฌ์ฉ์ฑ ๊ฐ์
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ์นด์นด์ค ์ฝํ
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- emtion app router
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- app router emotion
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- js ์ค์ฝํ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- emotion RSC
- suspense ๋์์๋ฆฌ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- ๊ตฌ๋ฆํค
Archives
- Today
- Total
Lennon FE
[๋ฐฑ์ค 5430๋ฒ] AC - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/5430
const fs = require('fs');
let [n, ...input] = fs.readFileSync('../input.txt').toString().trim().split('\n');
input = input.filter((v) => isNaN(v));
const result = [];
for (let i = 0; i < input.length; i += 2) {
let command = input[i].split('');
let arr = JSON.parse(input[i + 1]);
let isReverse = false;
let isError = false;
for (let j = 0; j < command.length; j++) {
if (command[j] === 'R') {
isReverse = !isReverse;
} else {
if (arr.length > 0) {
if (isReverse) {
arr.pop();
} else {
arr.shift();
}
} else {
isError = true;
break;
}
}
}
if (isError) {
console.log('error');
} else {
if (isReverse) {
console.log(JSON.stringify(arr.reverse()));
} else {
console.log(JSON.stringify(arr));
}
}
}
๊ณ์ ํ๋ ธ์ต๋๋ค๊ฐ ๋ ์ ์ด์ ๋ฅผ ์ฐพ์๋ณด๋ค๊ฐ ํด๊ฒฐ์ ๋ชป ํ๋ค. ๋ค๋ฅธ ์ฌ๋์ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํ๋ ๋ง์ง๋ง์ JSON ์ฒ๋ฆฌ๋ฅผ ํด์ฃผ์ง ์์์ ํ๋ฆฐ๊ฑฐ์๋ค...
์๋ง ๋ฐฐ์ด ๋ด๋ถ ๋์ด์ฐ๊ธฐ ๋๋ฌธ์ธ ๊ฒ ๊ฐ์๋ฐ ๋ฐฑ์ค ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ์์ ์ ๋ ฅ๊ฐ์ ๋ฐฐ์ด ๋ฌธ์์ด์ ์ค์ ex) " [1,2,3,4,5] " ์ด๋ฅผ ์ฒ๋ฆฌ๋ฅผ ์ํด JSON์ฒ๋ฆฌ๋ฅผ ํ ๊ฒ๋ ์ด์ด๊ฐ ์์๊ณ , ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ถ ๋ง์์ง๋ง ์ด๋ฐ ๊ฒ ๋๋ฌธ์ ํ๋ฆฐ๋ค๋ ๊ฒ ์์ด๋ฌ๋ํ๋ค. (์ด๊ฒ ๊ณจ๋ ๋ฌธ์ ์ธ ์ด์ ์ธ๊ฐ?)
๋ค์๋ถํฐ ์ ์ถ๋ ฅ์ ๋ ์ ๊ฒฝ์จ์ ํ์ด์ผ๊ฒ ๋ค.
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 1541๋ฒ] ์์ด๋ฒ๋ฆฐ ๊ดํธ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.02.15 |
---|---|
[๋ฐฑ์ค 1966๋ฒ] ํ๋ฆฐํฐ ํ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.02.15 |
[๋ฐฑ์ค 1062๋ฒ] ๊ฐ๋ฅด์นจ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.02.11 |
[๋ฐฑ์ค 3085๋ฒ] ์ฌํ๊ฒ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.02.06 |
[๋ฐฑ์ค 6603๋ฒ] ๋ก๋ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.02.06 |
Comments