-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKthMissingNumber.java
More file actions
34 lines (32 loc) · 857 Bytes
/
KthMissingNumber.java
File metadata and controls
34 lines (32 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<<<<<<< HEAD
//1539. Kth Missing Positive Number
class Solution {
public int findKthPositive(int[] arr, int k) {
int n = arr.length;
int i = 0, missingCount = 0, num = 1;
while(true){
if(i < n && arr[i] == num) i++;
else{
missingCount++;
if(missingCount == k) return num;
}
num++;
}
}
=======
//1539. Kth Missing Positive Number
class Solution {
public int findKthPositive(int[] arr, int k) {
int n = arr.length;
int i = 0, missingCount = 0, num = 1;
while(true){
if(i < n && arr[i] == num) i++;
else{
missingCount++;
if(missingCount == k) return num;
}
num++;
}
}
>>>>>>> be6ce0b427078b1421d5dd74adb2300dc02daeec
}