๐Algorithm
ํ๋ก๊ทธ๋๋จธ์ค ์ฝ๋ฉํ ์คํธ ํ์ด(js) > H-index(lv2)
devWarrior
2023. 6. 29. 21:00
๋ฌธ์ ๐ฝ
https://school.programmers.co.kr/learn/courses/30/lessons/42747
ํ๋ก๊ทธ๋๋จธ์ค
์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์ ๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์ ๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.
programmers.co.kr
๋ค๋ฅธ์ฌ๋ ํ์ด ๐ฝ
function solution(citations) {
citations = citations.sort(sorting);
var i = 0;
while(i + 1 <= citations[i]){
i++;
}
return i;
function sorting(a, b){
return b - a;
}
}
๋ดํ์ด๐ฝ
1. ์ฑ๊ณต โญ
function solution(citations) {
let answer = 0;
for(let i=citations.length; i>=1; --i){
let countCitations = citations.filter((value)=> value>=i).length
if(countCitations>=i){
answer=i;
break;
}
}
return answer;
}
๋๋์ ๐ฝ
๋ฌธ์ ๋ฅผ ๋ค์๋ณด๊ณ ์์ธ์ ๊ฒฝ์ฐ๋ฅผ ๋ค์ ํ์ธํด๋ณด์ ...