File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ 
2+ //https://leetcode.com/problems/design-hashset 
3+ var  MyHashSet  =  function ( )  { 
4+     this . set  =  [ ] ; 
5+ } ; 
6+ 
7+ /**  
8+  * Time O(1) | Space O(1) 
9+  * @param  {number } key 
10+  * @return  {void } 
11+  */ 
12+ MyHashSet . prototype . add  =  function ( key )  { 
13+     this . set [ key ]  =  key ; 
14+ } ; 
15+ 
16+ /**  
17+  * Time O(1) | Space O(1) 
18+  * @param  {number } key 
19+  * @return  {void } 
20+  */ 
21+ MyHashSet . prototype . remove  =  function ( key )  { 
22+     this . set [ key ]  =  undefined ; 
23+ } ; 
24+ 
25+ /**  
26+  * Time O(1) | Space O(1) 
27+  * @param  {number } key 
28+  * @return  {boolean } 
29+  */ 
30+ MyHashSet . prototype . contains  =  function ( key )  { 
31+     return  this . set [ key ]  !==  undefined ; 
32+ } ; 
33+ 
34+ /**  
35+  * Your MyHashSet object will be instantiated and called as such: 
36+  * var obj = new MyHashSet() 
37+  * obj.add(key) 
38+  * obj.remove(key) 
39+  * var param_3 = obj.contains(key) 
40+  */ 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments