1
var SmallestInfiniteSet = function () {
2
const s = new Set();
3
this.s = s;
4
for (let i = 1; i <= 1000; i++) s.add(i);
5
};
6

7
/**
8
* @return {number}
9
*/
10
SmallestInfiniteSet.prototype.popSmallest = function () {
11
const min = Math.min(...Array.from(this.s));
12
this.s.delete(min);
13
return min;
14
};
15

16
/**
17
* @param {number} num
18
* @return {void}
19
*/
20
SmallestInfiniteSet.prototype.addBack = function (num) {
21
this.s.add(num);
22
};
23

24
/**
25
* Your SmallestInfiniteSet object will be instantiated and called as such:
26
* var obj = new SmallestInfiniteSet()
27
* var param_1 = obj.popSmallest()
28
* obj.addBack(num)
29
*/

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0