Google | Phone | Kth missing number
Anonymous User
5183

Given a strictly ascending array of positive integers, output the Kth number that is missing from it.

For example:

  1. (2, 14, 16, 17) K = 4 output: 5 (explanation: missing numbers are 1,3,4,5,6,.. and find the Kth missing number which is 5 as K = 4)
  2. (8, 9) K = 1 output: 1
  3. (8, 9) K=1000000 output:1000002

Expected runtime O(log N) where N = array length

Comments (15)