夜深人静写bug
夜深人静写bug
全部文章
分类
题解(1)
归档
标签
去牛客网
登录
/
注册
夜深人静写bug的博客
全部文章
(共33篇)
题解 | #切蛋糕#
#include<iostream> #include<string> using namespace std; int main() { int n; cin >> n; if(n & (n-1) == 0) cout <...
C++
2023-12-27
1
195
题解 | #二叉树的后序遍历#
class Solution { public: vector<int> postorderTraversal(TreeNode* root) { vector<int> v; stack<TreeNode*> s; ...
2023-09-20
0
211
题解 | #二叉树的中序遍历#
class Solution { public: vector<int> inorderTraversal(TreeNode* root) { vector<int> ret; if(!root) return ret; ...
2023-09-18
0
224
题解 | #二叉树的最大深度#
class Solution { public: /* int maxDepth(TreeNode* root) { // write code here if(!root) return 0; queue<TreeNode*> q;...
2023-09-17
0
191
题解 | #二叉树的最大深度#
class Solution { public: int maxDepth(TreeNode* root) { // write code here if(!root) return 0; queue<TreeNode*> q; ...
2023-09-17
0
220
题解 | #求二叉树的层序遍历#
class Solution { public: vector<vector<int> > levelOrder(TreeNode* root) { // write code here vector<vector<int&...
2023-09-15
0
225
题解 | #二叉树的后序遍历#
//借助了先序非递归的方法,第一个循环就是对先序的改写了 //先序遍历时,弹出栈顶节点就访问,然后先压右孩子再压左孩子,循环直到栈空 //改写如下: //如果每次弹出栈顶元素就访问,并且先压左孩子再压右孩子,那么整体的访问顺序就是头右左;而后续遍历的顺序是啥? //不就是左右头嘛?和头右左是逆序的,...
2023-09-12
0
176
题解 | #二叉树的中序遍历#
class Solution { public: vector<int> inorderTraversal(TreeNode* root) { // write code here vector<int> ret; if...
2023-09-12
0
211
题解 | #二叉树的中序遍历#
class Solution { public: void lur(vector<int>& ret,TreeNode* root) { if(root == nullptr) return ; lur(ret,root->l...
2023-09-12
0
197
题解 | #二叉树的前序遍历#
class Solution { public: vector<int> ret; stack<TreeNode*> s; TreeNode* temp=nullptr; vector<int> preorderTraversal(...
2023-09-11
0
256
首页
上一页
1
2
3
4
下一页
末页