![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 63
weixin_42926060
这个作者很懒,什么都没留下…
展开
-
2021-08 Leetcode刷题记录
ref: https://www.cnblogs.com/grandyang/default.html?page=2 https://hk029.gitbooks.io/leetbook/content/ 计时统计:题目,算法,编码,调试,优化 must: 明确变量含义 逻辑场景覆盖 check: 状态初始化、更新与还原 边界条件:max/min初始化边界flag直接作为结果含义转换 累加等溢出 INT_MIN LONG_MIN opt: 关键注释 剪枝尽早提升性能 2021...原创 2021-08-07 15:32:45 · 129 阅读 · 0 评论 -
STL 常用
multiset<int> s; s.erase(2); // 删除所有2 s.erase(s.lower_bound(2)); //迭代器位置删除第一个2 string str = "-0123456789"; long a = std::atol(str.substr(3, str.length() - 3).c_str()); int b = std::atoi(str.su...原创 2019-12-21 14:20:49 · 131 阅读 · 0 评论 -
C++ map 查询 插入
定义pair的key map<pair<int,int>,double>hashMap map查询是否成存在key使用.count返回0/1 if(hashMap.count({a,b})==0) pair的key直接{a, b} map插入key直接hashMap[key]即可 hashMap[{a,b}]=0.25 dou...原创 2019-12-06 15:07:40 · 233 阅读 · 1 评论 -
C++ operator重载
priority_queue<vector<int>, vector<vector<int>>,cmp1> q; struct cmp1 { bool operator()(vector<int> &x, vector<int> &y) { // return pow(x[...原创 2019-12-05 10:26:59 · 78 阅读 · 0 评论 -
C++ vector 删除
一般来讲erase用得比较多,不注意也容易踩坑,例如: vector<int> vec{1, 4, 3, 2, 5, 2}; for(auto it = vec.begin(); it != vec.end(); it++){ if(*it < 3){ cout << "num is " << *it <<...原创 2019-12-02 14:48:39 · 181 阅读 · 0 评论