Kth Missing Positive Number

Binary Search on Answers DSA practice problem on Onlearn.

Difficulty: easy.

Topics: Find the kth missing positive integer from a strictly increasing array, Arrays, Brute Force, Binary Search, Time Complexity, Space Complexity, Loops, Conditional Statements, space complexity, counting, brute force, binary search, array traversal, time complexity analysis, Missing Number Problems.

Given a strictly increasing array vec of integers and a positive integer k, find the k th positive integer that is missing from the array. Input Specification: The input consists of an integer array vec and an integer k. Output Specification: Return the k th positive integer missing from vec. Example 1: Input: vec = [4, 7, 9, 10], k = 1 Output: 1 Explanation: The positive integers missing from the array are 1, 2, 3, 5, 6, 8, 11, 12, and so on. The 1st missing positive integer is 1. Example 2: Input: vec = [4, 7, 9, 10], k = 4 Output: 5 Explanation: The positive integers missing from the array are 1, 2, 3, 5, 6, 8, 11, 12, and so on. The 4th missing positive integer is 5.