class HashSet {
      private:
          int size = 1e6+2;
          vector<bool> v;
      public:
          /** Initialize your data structure here. */
          HashSet() {
              v.resize(size, false);
          }
          void add(int key) {
              v[key] = true;
          }
          void remove(int key) {
              v[key] = false;
          }
          /** Returns true if this set contains the specified element */
          bool contains(int key) {
              return v[key];
          }
      };
      /**
       * Your HashSet object will be instantiated and called as such:
       * Your HashSet object will be instantiated and called as such:
       * HashSet* obj = new HashSet();
       * HashSet* obj = new HashSet();
       * obj->add(key);
       * obj->add(key);
       * obj->remove(key);
       * obj->remove(key);
       * bool param_3 = obj->contains(key);
       * bool param_3 = obj->contains(key);
       */
       */
      
      Cpp language logo

      HashSet implementation

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.