h-index kotlin 정렬 알고리즘1 [프로그래머스, 코틀린] H-Index class Solution { fun solution(citations: IntArray): Int { // 인용 횟수를 내림차순으로 정렬 val sortedCitations = citations.sortedDescending() // H-Index를 찾기 위한 변수 var hIndex = 0 // 정렬된 배열을 순회하면서 조건에 맞는 최대 h를 찾음 for (i in sortedCitations.indices) { if (sortedCitations[i] >= i + 1) { hIndex = i + 1 } else { break .. 2025. 1. 10. 이전 1 다음