
function solution(citations) {
  let cnt = [];
  let h = 0;
  citations.sort((a, b) => b - a);
  h = citations[0];
  while (true) {
    cnt = citations.filter((citation) => h <= citation);
    if (cnt.length >= h) {
      return h;
    }
    h--;
  }
}
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;
  }
}
h-index를 찾을 때의 과정이 독특하다.
예를 들어 정렬된 citation이 [47, 22]이라면 while루프를 3번째 돌 때 3 <= citations[3]이 되므로 루프를 빠져나가고 2를 return 한다.
코드는 간단해보이지만 가독성은 떨어지므로 좋은 코드인지는 모르겠다.
테스트케이스에 대한 고민을 체계적으로 할 필요가 있다.