#2336 - Smallest Number in Infinite Set
You have a set containing all positive integers [1, 2, 3, …]. Implement the SmallestInfiniteSet class:
popSmallest()– removes and returns the smallest integer in the set.addBack(num)– addsnumback into the set if it is not already present.
| Input | Output |
|---|---|
Operations | Output |
popSmallest(), popSmallest(), popSmallest(), addBack(1), popSmallest(), popSmallest(), popSmallest() | [1, 2, 3, 1, 4, 5, 6] |