diff --git a/solved/LeetCode/Challenges/2020/January/06.kt b/solved/LeetCode/Challenges/2020/January/06.kt new file mode 100644 index 00000000..e3928dbc --- /dev/null +++ b/solved/LeetCode/Challenges/2020/January/06.kt @@ -0,0 +1,17 @@ +class Solution { + fun findKthPositive(arr: IntArray, k: Int): Int { + var missing = 0 + var cur = 0 + for (i in 1..(arr.size + k)) { + if (cur < arr.size && arr[cur] == i) { + cur++ + } else { + missing++ + } + if (missing == k) { + return i + } + } + error("Answer not found") + } +}