프로그래머스
H-Index
끝까지 처음처럼
2022. 9. 27. 14:15
728x90
class Solution {
fun solution(citations: IntArray): Int {
var answer = 0
val tempCitations = citations.sortedDescending()
for(i in tempCitations.maxOrNull()!! downTo 1){
if(tempCitations.count{e -> e >= i} >= i && tempCitations.count{e -> e <= i} <= i ){
answer = i
break
}
}
return answer
}
}
해당 문제는 H-index 에 대한 개념을 알고 있거나 이해를 했다면 쉽게 풀 수 있던 문제였던것 같습니다.
저의 경우 처음에 H-index 에 대한 개념을 잘못이해를 하여 일명 삽질(?) 을 많이 하였었지만 이해를 하고 나니 금방 풀렸던 문제 였습니다.