Skip to content

Commit b1b28fc

Browse files
committed
Create 0448-find-all-numbers-disappeared-in-an-array.kt
1 parent d65d5d9 commit b1b28fc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
fun findDisappearedNumbers(nums: IntArray): List<Int> {
3+
val res = ArrayList<Int>()
4+
for(i in nums.indices){
5+
val num = Math.abs(nums[i])
6+
nums[num-1] = Math.abs(nums[num-1]) * -1
7+
}
8+
for((i,v) in nums.withIndex()){
9+
if(v > 0) res.add(i+1)
10+
}
11+
return res
12+
}
13+
}

0 commit comments

Comments
 (0)