currentInteger
to 1, isPresent
as a hash set, and addedIntegers
as a min-heap.popSmallest()
, check if addedIntegers
is not empty and pop the smallest element from it, otherwise return currentInteger
and increment it.addBack(num)
, add num
to both isPresent
and addedIntegers
if num
is less than currentInteger
and not already present in isPresent
.