diff --git a/1206. Design Skiplist (Hard) b/1206. Design Skiplist (Hard) new file mode 100644 index 0000000..61ad7dd --- /dev/null +++ b/1206. Design Skiplist (Hard) @@ -0,0 +1,39 @@ +class Skiplist { +public: + + maps; + + Skiplist() { + + } + + bool search(int target) { + if(s.find(target)!=s.end()) + return true; + else + return false; + } + + void add(int num) { + s[num]++; + } + + bool erase(int num) { + if(s.find(num)==s.end()) + return false; + else{ + s[num]--; + if(s[num]==0) + s.erase(num); + return true; + } + } +}; + +/** + * Your Skiplist object will be instantiated and called as such: + * Skiplist* obj = new Skiplist(); + * bool param_1 = obj->search(target); + * obj->add(num); + * bool param_3 = obj->erase(num); + */