-
Notifications
You must be signed in to change notification settings - Fork 115
/
0705-DesignHashset.cs
43 lines (36 loc) · 1.02 KB
/
0705-DesignHashset.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//-----------------------------------------------------------------------------
// Runtime: 228ms
// Memory Usage: 49.1 MB
// Link: https://leetcode.com/submissions/detail/337002075/
//-----------------------------------------------------------------------------
namespace LeetCode
{
public class _0705_DesignHashset
{
private bool[] flags = new bool[1000001];
/** Initialize your data structure here. */
public _0705_DesignHashset()
{
}
public void Add(int key)
{
flags[key] = true;
}
public void Remove(int key)
{
flags[key] = false;
}
/** Returns true if this set contains the specified element */
public bool Contains(int key)
{
return flags[key];
}
}
/**
* Your MyHashSet object will be instantiated and called as such:
* MyHashSet obj = new MyHashSet();
* obj.Add(key);
* obj.Remove(key);
* bool param_3 = obj.Contains(key);
*/
}