【Leetcode_easy】705. Design HashSet
2024-09-01 13:56:30
problem
题意:
solution1:
class MyHashSet {
public:
/** Initialize your data structure here. */
MyHashSet() {
data.resize(, );
} void add(int key) {
data[key] = ;
} void remove(int key) {
data[key] = ;
} /** Returns true if this set contains the specified element */
bool contains(int key) {
//if(data[key]==1) return true;
//else return false;
return data[key]==;
}
vector<int> data;
}; /**
* 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);
*/
solution2:
参考
1. Leetcode_easy_705. Design HashSet;
2. Grandyang;
完
最新文章
- python正则表达式re
- innodb 存储引擎特性
- rocksDB 安装问题简单介绍
- iOS - Mac OS X 终端命令
- Svn win7系统下状态图标不显示-转载
- git设计哲学
- Topcoder SRM 637 (Div.2)
- MFC界面更新实现方法
- Visual Studio发布项目到远程服务器的步骤
- Oracle EBS-SQL (BOM-17):检查8层BOM.sql
- [置顶] CopyU!v2插件合集 [2013年7月18日更新]
- sql常用语句汇总
- 标准IO库
- Linux-进程描述(5)之进程环境
- tomcat的常用配置方法
- 结对编程-四则运算生成程序-GUI界面
- HTTP/2部署使用
- .net core使用ef core操作mysql数据库
- gparted 不能起作用的时候,用fdisk
- Codeforces Round #367 (Div. 2) D. Vasiliy&#39;s Multiset(01字典树求最大异或值)