把自己菜哭了
把自己菜哭了
全部文章
分类
题解(15)
归档
标签
去牛客网
登录
/
注册
把自己菜哭了的博客
全部文章
(共15篇)
题解 | 树的子结构
if(pre[left]==mid[tag]) 则 找到了根的位置(left是当前树范围终pre第一个元素) mid的起始位置到j-1为左子树数组范围,j+1到mid的终止位置为右子树的数组范围 pre的起始位置+1到pre+左子树大小为左子树的范围,pre+左子树大小+1到pre的终止位置为右子树...
C++
2022-03-08
0
254
题解 |二叉树的第K个节点
二叉搜索树以及中序遍历 /** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * TreeNode(int x) : val(x), left(nullptr), righ...
C++
2022-03-01
0
227
题解 | 按Z字形打印二叉树
使用队列以及reverse()函数 /* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), l...
C++
2022-03-01
0
266
题解 |按Z字形打印二叉树
利用栈实现 /* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), r...
C++
2022-03-01
0
290
题解 | 滑动窗口最大值
暴力破解 public: vector<int> maxInWindows(const vector<int>& num, unsigned int size) { vector<int>maxNum; ...
C++
2022-02-28
0
257
题解 | 反转单词序列
利用stringstream类的方法分割,栈进行反转 public: string ReverseSentence(string str) { if(str.empty()) return str; stringstream ss(str); ...
C++
字符串
2022-02-27
0
277
题解 | 栈的压入弹出序列
利用辅助栈 public: bool IsPopOrder(vector<int> pushV,vector<int> popV) { stack<int> stackV; int i=0,j=0; stac...
C++
2022-02-27
0
239
题解 | 包含MIN函数的栈
辅助栈关键在于每次都有入栈,入栈元素为最小元素,个数与s保持一致 private: stack<int> s,minStack; public: void push(int value) { if(minStack.empty()){ ...
C++
2022-02-27
0
252
题解 | #删除链表中的结点#
考虑到要删除多个节点,且头节点在其中 /* * * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : val(x), next(nullptr) {} * }; */ class Solu...
C++
2022-02-27
0
298
题解 | #删除链表中重复的结点#
新增一个头节点的思想值得学习 vHead /* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } }; */ class...
C++
2022-02-27
0
231
首页
上一页
1
2
下一页
末页