그냥 정렬치고 없는거있으면 리턴
정답
class Solution {
fun missingNumber(nums: IntArray): Int {
val numList = nums.sorted()
var res=0
for (i in numList){
if (res!=i){
return res
}
res+=1
}
return res
}
}
'알고리즘' 카테고리의 다른 글
릿코드 997. Find the Town Judge 코틀린 (0) | 2024.02.22 |
---|---|
릿코드 201. Bitwise AND of Numbers Range 코틀린 (0) | 2024.02.21 |
릿코드 231. Power of Two 코틀린 (0) | 2024.02.19 |
릿코드 1481. Least Number of Unique Integers after K Removals 코틀린 (0) | 2024.02.16 |
릿코드 2971. Find Polygon With the Largest Perimeter 코틀린 (0) | 2024.02.15 |