Find Missing Integer
Updated
Problem statement
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.
Function
findMissingInteger(arr: int[], k: long) → long
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
Example 1
arr = [1, 4, 7, 3, 4]k = 5return = 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 interview questions
- Missing IntervalsOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Alternate Odd and Even Numbers with Two GoroutinesPHONE SCREEN · Seen Nov 2026
- Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
- Count Pairs of Overlapping SquaresCapital One · OACapital One interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Out-of-Order Bank Ledger BalancesPerplexity AI · OAPerplexity AI interview questions
- Find Idle Skills QueryAmazon · OA
- Time Based Key-Value StoreCoalition · OA
- Time Based Key-Value StoreAtlassian · OAAtlassian interview questions
- Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
- Credit Accounts with Scheduled TransfersAirbnb · OAAirbnb interview questions
- Banking System with Historical SnapshotsCoinbase · OACoinbase interview questions