Skip to content

Commit 2b38afe

Browse files
committed
[Week4](gmlwls96) Missing number
1 parent 2f133cb commit 2b38afe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

missing-number/gmlwls96.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
fun missingNumber(nums: IntArray): Int {
3+
nums.sort()
4+
var num = nums[0]
5+
for (i in 1 until nums.size) {
6+
if (nums[i] != (num + 1)) {
7+
return num + 1
8+
}
9+
num = nums[i]
10+
}
11+
return num + 1
12+
}
13+
}

0 commit comments

Comments
 (0)