diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/smallest_num_set.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/smallest_num_set.cpp')
-rw-r--r-- | other/smallest_num_set.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/other/smallest_num_set.cpp b/other/smallest_num_set.cpp deleted file mode 100644 index f05147b..0000000 --- a/other/smallest_num_set.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// 2336. Smallest Number in Infinite Set -#include "leetcode.h" - -/* - * you have a set which contains all positive integers [1,2,3,...] - * implement the SmallestInfiniteSet class: - * - SmallestInfiniteSet() initialises the SmallestInfiniteSet - * object to contain all positive integers - * - int popSmallest() removes and returns the smallest integer - * contained in the infinite set - * - void addBack(int num) adds a positive integer num back into - * the infinite set, if it is not already in the infinite set - */ - -class SmallestInfiniteSet { -public: - int k = 1; - unordered_map<int, int> um; - SmallestInfiniteSet() { - for (int i = 1; i <= 1000; i++) - um[i] = i; - } - int popSmallest() { - int d = um[k]; - um.erase(k); - for (int i = k + 1; i <= 1000; i++) { - if (um.find(i) != um.end()) { - k = i; - break; - } - } - return d; - } - void addBack(int num) { - um[num] = num; - if (num < k) - k = num; - } -}; - -int main() { - SmallestInfiniteSet *obj = new SmallestInfiniteSet(); - int param_1 = obj->popSmallest(); - obj->addBack(2); -} |