🧠 Before you code — what pattern fits?
You have a set containing all positive integers [1, 2, 3, …]. Implement SmallestInfiniteSet: popSmallest() removes and returns the smallest integer in the set; addBack(num) adds num back if it was removed.
addBack(2); popSmallest()=1; popSmallest()=2; popSmallest()=3; addBack(1); popSmallest()=1
🎬 Video explanation · codestorywithMIK
Your solution runs against 1 unit tests, including edge and large-value cases.
Loading...
Test console · 1 unit tests
Submit your code to run it against all 1 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.