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
- ์นด์นด์ค ์ฝํ
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- js
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- suspense ๋ณ๋ชฉํ์
- app router emotion
- ๋ฐฑ์ค 2108 nodejs
- emtion app router
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- suspense ๋์์๋ฆฌ
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ์ต์ ๋์ฒด์ด๋
- ์ฌ์ฉ์ฑ ๊ฐ์
- emotion RSC
- ๊ตฌ๋ฆํค
- js ์ค์ฝํ
- next13 emotion
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- js ๋ฌธ์์ด ์์ถ
- suspense react-query
- suspense ๋น๋๊ธฐ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- ๋ฐฑ์ค 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:
- ์ค์ฝํ
Archives
- Today
- Total
Lennon FE
[ํ๋ก๊ทธ๋๋จธ์ค] 1์ฐจ ์บ์ (javaScript) ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
https://programmers.co.kr/learn/courses/30/lessons/17680
function solution(cacheSize, cities) {
const city = cities.map(a => a.toLowerCase());
// ๋ฐฐ์ด ๋ด ์์ ์๋ฌธ์๋ก
let queue = [];
let time = 0;
for(let i = 0; i < city.length; i++){
if(!queue.includes(city[i])){ // ํ์ ๋์๊ฐ ์กด์ฌํ์ง ์์ผ๋ฉด
time+=5;
queue.push(city[i]);
if(queue.length > cacheSize){ // ์บ์์ฌ์ด์ฆ๋ฅผ ๋์ผ๋ฉด ์ ์์ ์ญ์
queue.shift();
}
}
else{ // ๋์๊ฐ ํ์ ์์ผ๋ฉด
time++;
let idx = queue.indexOf(city[i]);
queue.splice(idx, 1);
queue.push(city[i]); // ์ธ๋ฑ์ค ์ฐพ์์ ์ ๊ฑฐ ํ ๋งจ ๋ค์ ์ฝ์
}
}
return time;
}
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ๊ธฐ๋ฅ ๊ฐ๋ฐ (js) (0) | 2021.10.25 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ํฌ๋ ์ธ ์ธํ๋ฝ๊ธฐ (javascript) (0) | 2021.10.20 |
[ํ๋ก๊ทธ๋๋จธ์ค] ํ๋ ์ฆ 4๋ธ๋ก (javascript) (0) | 2021.09.25 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ (javascript) (0) | 2021.09.25 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ์์ถ (javascript) (0) | 2021.09.25 |
Comments