In the context of data analysis and machine learning, a dataset containing an array of integers has been provided. Each integer is denoted as arr[i] (0 ≤ i < n). The task in this data-centric domain is to predict the kth smallest positive integer that is not found within the dataset, arr.
Note: The smallest positive integer is 1.
Complete the function findMissingInteger in the editor below.
findMissingInteger takes the following parameter(s):
int arr[n]: a machine learning datasetlong k: find thekthsmallest positive integer that is not present in the dataset
Returns
long: the kth smallest positive integer that is not in the dataset
Examples
01 · Example 1
arr = [1, 4, 7, 3, 4] k = 5 return = 9
The first five missing positive integers are
[2, 5, 6, 8, 9]. The 5th smallest positive integer not in the dataset is 9.Constraints
1 ≤ n ≤ 2 * 10^51 ≤ arr[i] ≤ 10^91 ≤ k ≤ 10^12
More IBM problems
- Count Descending SubarraysOA · Seen Apr 2026
- Count Power Products in RangeOA · Seen Apr 2026
- Minimum Operations to Make Alternating Binary StringSeen Feb 2026
- Minimum Number of Non-Empty Disjoint SegmentsSeen Feb 2026
- Count Unstable ProcessesOA · Seen Feb 2026
- Longest Balanced Binary SubarrayOA · Seen Feb 2026
- Process Execution TimeOA · Seen Nov 2025
- Service Timeout DetectionOA · Seen Nov 2025
public long findMissingInteger(int[] arr, long k) {
// write your code here
}
arr[1, 4, 7, 3, 4]
k5
expected9
sign in to submit