Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Kth Missing Number in Series

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Kth Missing Number in Series. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Cimpress Technology processes sorted numeric series for product and fulfillment workflows. Given a strictly increasing array of positive integers with some values missing from the sequence of all positive integers, return the kth missing positive integer.

The array contains only observed values. Missing values before the first element and between or after observed values all count. Use an efficient algorithm that avoids scanning every missing value when the array is large.

Formal Specification

Implement find_kth_missing(nums, k).

  • Input: nums, a strictly increasing list of positive integers, and k, a positive integer.
  • Output: The kth positive integer that does not appear in nums, returned as an integer.

Constraints

  • 1 <= len(nums) <= 10^5
  • 1 <= nums[i] <= 10^9
  • nums is strictly increasing
  • 1 <= k <= 10^9

Function Signature

def find_kth_missing(nums, k):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output