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 ๋ณ๋ชฉํ์
- js ๋ฌธ์์ด ์์ถ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- js ์ค์ฝํ
- ๋ฐฑ์ค 1339๋ฒ js
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- emtion app router
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ๊ตฌ๋ฆํค
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- emotion RSC
- app router emotion
- ์ฌ์ฉ์ฑ ๊ฐ์
- js
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- suspense ๋์์๋ฆฌ
- ์ต์ ๋์ฒด์ด๋
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- suspense ๋น๋๊ธฐ
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- suspense react-query
- ๋ฐฑ์ค 2108 nodejs
- ์ค์ฝํ
- next13 emotion
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- ์นด์นด์ค ์ฝํ
Archives
- Today
- Total
Lennon FE
[ํ๋ก๊ทธ๋๋จธ์ค] ์ํด๋ฆฌ ์ฑ๋ฆฐ์ง 6์ฃผ์ฐจ (javascript ํ์ด) ๋ณธ๋ฌธ
๐ฅ Algorithm/Programmers
[ํ๋ก๊ทธ๋๋จธ์ค] ์ํด๋ฆฌ ์ฑ๋ฆฐ์ง 6์ฃผ์ฐจ (javascript ํ์ด)
Lennon 2021. 9. 25. 17:42728x90
๋ฐ์ํ
https://programmers.co.kr/learn/courses/30/lessons/85002?language=javascript
function solution(weights, head2head) {
let winCount = 0;
let loseCount = 0;
let heavyCount = 0;
let answer = [];
for(let i = 0; i < head2head.length; i++){
for(let j = 0; j < head2head[i].length; j++){
let res = weights[i];
if(head2head[i][j] === "W"){
winCount++;
if(res < weights[j]) heavyCount++;
}
else if(head2head[i][j] === "L") loseCount++;
}
if(loseCount+winCount === 0){
answer.push({W : 0, Up : heavyCount, Weight: weights[i], Number : i+1});
}
else answer.push({W : winCount / (loseCount+winCount), Up : heavyCount, Weight: weights[i], Number : i+1});
winCount = 0;
heavyCount = 0;
loseCount = 0;
}
answer.sort((a,b) => {
if(b.W !== a.W) return b.W - a.W;
else if(b.W === a.W && b.Up === a.Up && a.Weight === b.Wight) return a.Weight - b.Weight;
else if(b.W === a.W && b.Up === a.Up ) return b.Weight - a.Weight;
else if(b.W === a.W) return b.Up - a.Up;
})
// console.log(answer);
return answer.reduce((cur,arr) => {
return cur.concat(arr.Number);
}, []);
}
์ ๋ ฌ์ด ์ค์ํ ๋ฌธ์ ์๋ค!
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] 1์ฐจ ์บ์ (javaScript) (0) | 2021.10.07 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ํ๋ ์ฆ 4๋ธ๋ก (javascript) (0) | 2021.09.25 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ (javascript) (0) | 2021.09.25 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ์์ถ (javascript) (0) | 2021.09.25 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ํด๋ฆฌ ์ฑ๋ฆฐ์ง 4์ฃผ ์ฐจ (javascript) (0) | 2021.08.25 |
Comments