1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| class Solution { fun solution(citations: IntArray): Int { var h = 0 var count = 0 val citedList = mutableListOf<Int>() val uncitedList = mutableListOf<Int>()
citations.sort()
while (count <= citations.size) { citations.forEach { if (it >= count) citedList.add(it) else uncitedList.add(it)
if (citedList.size >= count && uncitedList.size <= count) h = count } count += 1 citedList.clear() uncitedList.clear() } return h } }
|