用vector实现邻接表 vector <int> G[100]; //表示有100个顶点的图的邻接表 G[u].push_back(v); //从顶点u 向顶点v 画边,即在相当于创建一个二维数组G[100][i] //搜索与顶点u 相邻的顶点v for( int i = 0; i < G[u]. ...
分类:
其他好文 时间:
2020-04-02 22:44:38
阅读次数:
93
1 class Solution 2 { 3 public: 4 vector<int> getRow(int k) 5 { 6 int n = k + 1; 7 vector<vector<int>> ans; 8 for(int i = 0;i < n;i ++) 9 { 10 ans.push ...
分类:
其他好文 时间:
2020-04-01 17:49:37
阅读次数:
65
描述 使用队列实现栈的下列操作: push(x) 元素 x 入栈 pop() 移除栈顶元素 top() 获取栈顶元素 empty() 返回栈是否为空 注意: 你只能使用队列的基本操作 也就是?push to back, peek/pop from front, size, 和?is empty?这些 ...
分类:
其他好文 时间:
2020-04-01 12:49:21
阅读次数:
48
```cpp #include #define vint vector using namespace std; vint hread(){ vint r; string s; cin>>s; for(register int i=s.size()-1;i>=0;i--) r.push_back(s... ...
分类:
其他好文 时间:
2020-04-01 00:32:56
阅读次数:
56
使用队列实现栈的下列操作: push(x) -- 元素 x 入栈pop() -- 移除栈顶元素top() -- 获取栈顶元素empty() -- 返回栈是否为空注意: 你只能使用队列的基本操作-- 也就是 push to back, peek/pop from front, size, 和 is e ...
分类:
其他好文 时间:
2020-03-31 19:26:48
阅读次数:
100
A. 签到题1。 #include<bits/stdc++.h> #define fi first #define sd second #define lson (nd<<1) #define rson (nd+nd+1) #define PB push_back #define mid (l+r> ...
分类:
其他好文 时间:
2020-03-29 12:51:24
阅读次数:
76
2.1 vector<类型> v 声明了一个容器; 2.2 尾插 v.push_back(); 2.3 起始迭代器 v.begin() 指向容器中第一个元素; 2.4 结束迭代器 v.end() 指向容器中最后一个元素的下一个位置; 2.5 三种方式去遍历vector迭代器:其中注意使用 for_e ...
分类:
编程语言 时间:
2020-03-21 13:09:26
阅读次数:
65
题目地址:https://leetcode-cn.com/problems/dui-lie-de-zui-da-zhi-lcof/ 题目描述 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都是 ...
分类:
编程语言 时间:
2020-03-18 09:18:46
阅读次数:
69
1 class Solution 2 { 3 public: 4 bool isPalindrome(int x) 5 { 6 if(x < 0) return false; 7 vector<int> nums; 8 while(x) 9 { 10 nums.push_back(x % 10); ...
分类:
其他好文 时间:
2020-03-15 18:44:40
阅读次数:
41
1 def createScene(): 2 geode = osg.Geode() 3 pointsGeom = osg.Geometry() 4 vertices = osg.Vec3Array() 5 vertices.push_back((-1.02168, -2.15188e-09, 0. ...
分类:
编程语言 时间:
2020-03-15 11:42:40
阅读次数:
81