Kth Missing Positive Number (for E4 :)
Updated
Problem statement
LC 1539~ The other question was LC 498~~
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.
Return the kth positive integer that is missing from this array.
Function
findKthPositive(arr: int[], k: int) → int
Complete the function findKthPositive in the editor.
findKthPositive has the following parameters:
- 1.
int[] arr: an array of integers - 2.
int k: an integer
Returns
int: the kth missing positive integer
- Constraints
1 <= arr.length <= 1000 1 <= arr[i] <= 10001 <= k <= 1000arr[i] < arr[j]for1 <= i < j <= arr.length
Follow up
Could you solve this problem in less than O(n) complexity?
Examples
Example 1
arr = [2,3,4,7,11]k = 5return = 9The missing positive integers are [1,5,6,8,9,10,12,...]. The 5th missing positive integer is 9.
Example 2
arr = [1,2,3,4]k = 2return = 6The missing positive integers are [5,6,7,...]. The 2nd missing positive integer is 6.
More Meta Phone Screen questions
- Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
- First Element Greater Than KPHONE SCREEN · Seen Nov 2026
- Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
- Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
- Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026
- Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Values Exclusive to the Current UserPHONE SCREEN · Seen Sep 2026
- First Bad Version in a Monotone ArrayPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Track New Values in Sorted OrderBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Price at Query TimestampsGoogle · PHONE SCREENGoogle interview questions
- First Missing Number in a Consecutive ArrayArista Networks · OA · PHONE SCREENArista Networks interview questions
- Messages in an Inclusive Timestamp RangeAttentive · PHONE SCREEN · ONSITE INTERVIEWAttentive interview questions
- Target Sum Across Two Sorted ArraysSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Leftmost Binary Search MatchByteDance · PHONE SCREENByteDance interview questions
- Count Occurrences in a Sorted ArrayAdobe · PHONE SCREEN · ONSITE INTERVIEWAdobe interview questions
- Find the First Target IndexSuperhuman · PHONE SCREENSuperhuman interview questions
- First Target IndexGrammarly · PHONE SCREEN
- Ceiling Value in a Sorted ArrayPeopleStrong · PHONE SCREENPeopleStrong interview questions
Meta interview experiences
- Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
- Meta Business Support Engineer Phone Screen: 1 Experience
- Meta Software Engineer Onsite Questions: 3 Experiences
- Meta AI Native Engineer OA and Onsite: 1 Experience
- Meta AI-Native Coding Interview: 3 Experiences
- Meta Production Engineer Intern Questions: 6 Experiences