set存删掉的数
- v维护下一个最小值
class SmallestInfiniteSet {
int v=1;
set<int> s;
public:
SmallestInfiniteSet() {
priority_queue<int,vector<int>,greater<int>> heap;
}
int popSmallest() {
int ans = v;
s.insert(v);
do{
v ++;
}while(s.count(v));
return ans;
}
void addBack(int num) {
if(s.count(num))
s.erase(num);
v = min(v,num);
}
};