码迷,mamicode.com
首页 >  
搜索关键字:哈希桶 开链式 伪函数 vector    ( 11688个结果
set相关操作总结(待续)
//一些和vector,list类似的操作就没有总结#include <set> #include <list> #include <iostream> using namespace std; void count_set(const set<int> &set1, const set<int> ...
分类:其他好文   时间:2020-04-23 13:47:44    阅读次数:66
【剑指offer】【位运算】56 - II. 数组中数字出现的次数 II
位运算 + 状态转移 ...
分类:编程语言   时间:2020-04-23 13:46:04    阅读次数:73
355. 设计推特
1 class Twitter 2 { 3 public: 4 unordered_map<int,priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>> u;//用户 -> (出现的次数,推文) 小根堆 ...
分类:其他好文   时间:2020-04-22 23:00:19    阅读次数:114
347. 前 K 个高频元素
1 class Solution 2 { 3 public: 4 vector<int> topKFrequent(vector<int>& nums, int k) 5 { 6 vector<int> res; 7 unordered_map<int,int> hash; 8 for(auto a ...
分类:其他好文   时间:2020-04-22 19:38:30    阅读次数:43
344. 反转字符串
1 class Solution 2 { 3 public: 4 void reverseString(vector<char>& s) 5 { 6 int n = s.size(); 7 for(int i = 0;i < n/2;i ++) swap(s[i],s[n - i - 1]); 8 ...
分类:其他好文   时间:2020-04-22 19:35:57    阅读次数:50
leetcode 199 二叉树的右视图
leetcode "199. 二叉树的右视图" 因为某些比赛导致三天没写编程题,回来之后发现自己好像啥都不会了,写每一题都要花费好长时间/_ \ 牢骚结束:二叉树的遍历一般用dfs或者bfs,dfs一般用于前中后序遍历,bfs一般用于层序遍历 方法一:这一题最直观的解法就是得到二叉树的层序遍历,然后 ...
分类:其他好文   时间:2020-04-22 16:17:55    阅读次数:61
STL—— 容器(vector)元素的删除
1. clear() 将整个 vector 都删除 使用 vectorname.clear() 可以将整个vector 中的元素全部删除,但是内存不会释放,如下代码: 1 #include <iostream> 2 #include <vector> 3 4 using namespace std; ...
分类:其他好文   时间:2020-04-22 10:02:16    阅读次数:56
二叉树的右视图
给定一棵二叉树,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。示例:输入: [1,2,3,null,5,null,4]输出: [1, 3, 4]解释: 1 rightSideView(TreeNode* root) { vector ans; if(root==NULL)... ...
分类:其他好文   时间:2020-04-22 09:54:24    阅读次数:52
239.Sliding Window Maximum
题目描述 Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the ...
分类:Windows程序   时间:2020-04-21 23:44:12    阅读次数:95
331. 验证二叉树的前序序列化
1 //空节点的个数 = 非空节点个数 + 1 2 class Solution 3 { 4 vector<string> res; 5 void spilt(string s,char c) 6 { 7 istringstream iss(s); 8 string temp; 9 while(ge ...
分类:其他好文   时间:2020-04-21 22:26:34    阅读次数:87
11688条   上一页 1 ... 82 83 84 85 86 ... 1169 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!