感觉就是模拟它的两个过程就行了啊
class SmallestInfiniteSet:
def __init__(self):
self.small = 1
self.delset = set()
def popSmallest(self) -> int:
ans = self.small
self.delset.add(self.small)
while self.small in self.delset:
self.small += 1
return ans
def addBack(self, num: int) -> None:
if num not in self.delset:
return
self.delset.remove(num)
if num < self.small:
self.small = num