Leetcode 2336. Smallest Number in Infinite Set
Maintain an infinite set of positive integers that supports popSmallest(), which removes and returns the current smallest element, and addBack(num), which re-inserts a number if it's missing. The challenge is to efficiently track the next unused integer while handling reinserts so popSmallest always returns the smallest available (constraints: num ≤ 1000, ≤1000 operations).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.