프로그래머스 Lv.2: H-Index

Steve·2021년 11월 13일

https://programmers.co.kr/learn/courses/30/lessons/42747

문제를 도대체 어떻게 풀어야 할지 감이 안와서 풀이를 보고 푼 문제이다.
결론적으로 인터넷에 H-Index를 구하는 방식이 나와 있다.

https://www.ibric.org/myboard/read.php?Board=news&id=270333

즉 피인용수를 내림차순한 다음, 논문 수 i를 만들어서 논문 수가 피인용수보다 작아지기 직전까지 ++ 해주면 된다.

function solution(citations){
    citations = citations.sort((a,b) => b-a);
    let i = 0;
    while(i+1 <= citations[i]) i++;
    return i;
}
profile
배우는 가장 좋은 방법은 가르치는 것이다.

0개의 댓글