์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 1339๋ฒ js
- app router emotion
- suspense ๋ณ๋ชฉํ์
- js
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ์นด์นด์ค ์ฝํ
- emotion RSC
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- ์ฌ์ฉ์ฑ ๊ฐ์
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- emtion app router
- js ์ค์ฝํ
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- ์ค์ฝํ
- ๋ฐฑ์ค 2108 nodejs
- suspense ๋น๋๊ธฐ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- ๊ตฌ๋ฆํค
- suspense ๋์์๋ฆฌ
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- js ๋ฌธ์์ด ์์ถ
- next13 emotion
- suspense react-query
- ์ต์ ๋์ฒด์ด๋
- Today
- Total
Lennon FE
[๋ฐฑ์ค 17298๋ฒ] ์คํฐ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
[๋ฐฑ์ค 17298๋ฒ] ์คํฐ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon 2022. 1. 21. 17:21https://www.acmicpc.net/problem/17298
const fs = require('fs');
let input = fs.readFileSync('dev/stdin').toString().trim().split('\n');
input.shift();
input = input[0].split(' ').map((v) => +v);
let arr = [];
let answer = new Array(input.length).fill(-1);
for (let i = 0; i < input.length; i++) {
while (arr.length && input[arr[arr.length - 1]] < input[i]) {
answer[arr.pop()] = input[i];
}
arr.push(i);
}
console.log(answer.join(' '));
์ฐ์ input ๊ธธ์ด๋งํผ -1์ ์ฑ์ด ๋ฐฐ์ด์ ์์ฑํ๋ค.
๊ทธ ํ ๋จ์ถํ๊ฐ๋ฅผ ํตํด arr๋ฐฐ์ด์ ๊ธธ์ด๊ฐ 0์ด ์๋ ๊ฐ์ ๋ํด input[i]๊ฐ๊ณผ input[arr[arr.length-1]]์ ๊ฐ์ ๋น๊ตํ๋ค.
์ฆ ์ผ์ชฝ ๊ฐ๊ณผ ๋น๊ตํด์ ์์ ๋ณด๋ค ํฐ ๊ฐ์ ์ฐพ๋ ๊ฒ์ด๋ค.
3,4,6,7์ ์๋ก ๋ค์ด๋ณด์.
input = [3,5,2,7]
answer = [-1, -1, -1, -1]
arr = [ ]
i = 0 // ์ while๋ฌธ 0๋ฒ ์ํ
answer = [-1, -1, -1, -1]
arr = [0]
i = 1 // ์ while๋ฌธ 1๋ฒ ์ํ
answer = [ 5, -1, -1, -1 ]
arr = [ 1 ]
i = 2 // ์ while๋ฌธ 0๋ฒ ์ํ
answer = [ 5, -1, -1, -1 ]
arr = [ 1 , 2]
i = 3 // ์ while๋ฌธ 2๋ฒ ์ํ
answer = [ 5, 7, 7, -1 ]
arr = [3]
์ฝ๋์ ํจ๊ป ๋ณด๋ฉด ์ฝ๊ฒ ์ดํดํ ์ ์๋ค.