package com.fishercoder.solutions;

import java.util.HashMap;
import java.util.Map;

/**
 * 705. Design HashSet
 *
 * Design a HashSet without using any built-in hash table libraries.
 *
 * To be specific, your design should include these functions:
 *
 * add(value): Insert a value into the HashSet.
 * contains(value) : Return whether the value exists in the HashSet or not.
 * remove(value): Remove a value in the HashSet. If the value does not exist in the HashSet, do nothing.
 *
 * Example:
 *
 * MyHashSet hashSet = new MyHashSet();
 * hashSet.add(1);
 * hashSet.add(2);
 * hashSet.contains(1);    // returns true
 * hashSet.contains(3);    // returns false (not found)
 * hashSet.add(2);
 * hashSet.contains(2);    // returns true
 * hashSet.remove(2);
 * hashSet.contains(2);    // returns false (already removed)
 *
 * Note:
 *
 * All values will be in the range of [0, 1000000].
 * The number of operations will be in the range of [1, 10000].
 * Please do not use the built-in HashSet library.
 */
public class _705 {
  public static class Solution1 {
    class MyHashSet {
      Map<Integer, Integer> map;

      /** Initialize your data structure here. */
      public MyHashSet() {
        map = new HashMap<>();
      }

      public void add(int key) {
        map.put(key, 0);
      }

      public void remove(int key) {
        if (map.containsKey(key)) {
          map.remove(key);
        }
      }

      /** Returns true if this set contains the specified element */
      public boolean contains(int key) {
        return map.containsKey(key);
      }
    }
  }
}

@@ -82,995 +82,232 @@
 p;%0A%0A
-/**%0A * 705. Design HashSet%0A *%0A * Design a HashSet without using any built-in hash table libraries.%0A *%0A * To be specific, your design should include these functions:%0A *%0A * add(value): Insert a value into the HashSet.%0A * contains(value) : Return whether the value exists in the HashSet or not.%0A * remove(value): Remove a value in the HashSet. If the value does not exist in the HashSet, do nothing.%0A *%0A * Example:%0A *%0A * MyHashSet hashSet = new MyHashSet();%0A * hashSet.add(1);%0A * hashSet.add(2);%0A * hashSet.contains(1);    // returns true%0A * hashSet.contains(3);    // returns false (not found)%0A * hashSet.add(2);%0A * hashSet.contains(2);    // returns true%0A * hashSet.remove(2);%0A * hashSet.contains(2);    // returns false (already removed)%0A *%0A * Note:%0A *%0A * All values will be in the range of %5B0, 1000000%5D.%0A * The number of operations will be in the range of %5B1, 10000%5D.%0A * Please do not use the built-in HashSet library.%0A */%0Apublic class _705 %7B%0A  public static class Solution1 %7B%0A    class
+public class _705 %7B%0A    public static class Solution1 %7B%0A        class MyHashSet %7B%0A            Map%3CInteger, Integer%3E map;%0A%0A            /**%0A             * Initialize your data structure here.%0A             */%0A            public
  MyH
@@ -304,32 +304,34 @@
 public MyHashSet
+()
  %7B%0A      Map%3CInt
@@ -327,113 +327,10 @@
     
-Map%3CInteger, Integer%3E map;%0A%0A      /** Initialize your data structure here. */%0A      public MyHashSet() %7B%0A
+  
     
@@ -354,35 +354,47 @@
 hMap%3C%3E();%0A      
+     
+ 
 %7D%0A%0A
+      
       public voi
@@ -402,32 +402,40 @@
  add(int key) %7B%0A
+        
         map.put(
@@ -445,27 +445,39 @@
 , 0);%0A      
+  
-%7D%0A%0A
+    %7D%0A%0A      
       public
@@ -508,16 +508,24 @@
         
+       
+ 
 if (map.
@@ -540,24 +540,34 @@
 Key(key)) %7B%0A
+          
           ma
@@ -585,26 +585,40 @@
 y);%0A        
+      
-%7D%0A
+  %7D%0A      
       %7D%0A%0A   
@@ -620,18 +620,39 @@
 %0A%0A      
-/*
+      /**%0A             
 * Return
@@ -700,20 +700,39 @@
  element
- */%0A
+%0A             */%0A      
       pu
@@ -772,16 +772,24 @@
         
+   
+     
 return m
@@ -819,16 +819,28 @@
     
+      %7D%0A        
 %7D%0A  
-  %7D%0A
   %7D%0A

refactor 705