Problems > The K-th Missing Number > Editorial

The K-th Missing Number — Solution & Editorial

Back to the Problem

Before index i (0-based), exactly a[i] − (i+1) numbers are missing. Binary search the first index where that count reaches K; the answer is lo + K.

Complexity: O(log N)