摘要:
1 struct cmp 2 { 3 bool operator()(pair<string,int> const &left,pair<string,int> const &right) 4 { 5 if(left.second == right.second) return left.first 阅读全文
posted @ 2020-04-09 22:04
Jinxiaobo0509
阅读(140)
评论(0)
推荐(0)
摘要:
1 class UnionFind 2 { 3 public: 4 int count; // 记录连通分量个数 5 vector<int> parent; // 存储若干棵树 6 vector<int> size; // 记录每棵树包含的节点数 7 8 UnionFind(int n) 9 { 1 阅读全文
posted @ 2020-04-09 21:27
Jinxiaobo0509
阅读(157)
评论(0)
推荐(0)
摘要:
1 class UnionFind 2 { 3 public: 4 vector<int> parent; // 存储若干棵树 5 int count; 6 UnionFind(int n) 7 { 8 count = n; 9 for (int i = 0; i < n; i++) parent. 阅读全文
posted @ 2020-04-09 21:25
Jinxiaobo0509
阅读(178)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 vector<int> p; 4 5 int find(int x) 6 { 7 if(p[x] != x) p[x] = find(p[x]); 8 return p[x]; 9 } 10 public: 11 int findCircleNum(ve 阅读全文
posted @ 2020-04-09 20:46
Jinxiaobo0509
阅读(104)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 int subarraySum(vector<int>& nums, int k) 5 { 6 unordered_map<int,int> hash; 7 hash[0] = 1; 8 9 int res = 0; 10 for(i 阅读全文
posted @ 2020-04-09 19:15
Jinxiaobo0509
阅读(119)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 int subarraysDivByK(vector<int>& nums, int k) 5 { 6 unordered_map<int,int> hash; 7 hash[0] = 1; 8 9 int res = 0; 10 f 阅读全文
posted @ 2020-04-09 19:14
Jinxiaobo0509
阅读(229)
评论(0)
推荐(0)
摘要:
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), 阅读全文
posted @ 2020-04-09 18:18
Jinxiaobo0509
阅读(120)
评论(0)
推荐(0)
摘要:
1 class MyHashMap 2 { 3 public: 4 const static int N = 20011; 5 vector<list<pair<int,int>>> hash; 6 7 MyHashMap() 8 { 9 hash = vector<list<pair<int,in 阅读全文
posted @ 2020-04-09 17:36
Jinxiaobo0509
阅读(298)
评论(0)
推荐(0)
摘要:
1 //开放寻址法 2 class MyHashMap 3 { 4 public: 5 const static int N = 2000003; 6 int hash_key[N], hash_value[N]; 7 8 MyHashMap() 9 { 10 memset(hash_key, -1 阅读全文
posted @ 2020-04-09 17:32
Jinxiaobo0509
阅读(730)
评论(0)
推荐(0)
摘要:
1 //开放寻址法 2 class MyHashMap 3 { 4 public: 5 const static int N = 2000003; 6 int hash_key[N], hash_value[N]; 7 8 MyHashMap() 9 { 10 memset(hash_key, -1 阅读全文
posted @ 2020-04-09 17:15
Jinxiaobo0509
阅读(121)
评论(0)
推荐(0)

浙公网安备 33010602011771号