题目:
https://leetcode-cn.com/problems/design-hashset/
import java.util.ArrayList; import java.util.List; public class _705_MyHashSet { private List<Integer> list; public _705_MyHashSet() { list = new ArrayList<>(); } public void add(int key) { if (!contains(key)) { list.add(key); } } public void remove(int key) { if (contains(key)) { list.remove((Integer) key); } } /** * Returns true if this set contains the specified element */ public boolean contains(int key) { return list.contains(key); } }