会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
tianmaster
博客园
首页
新随笔
联系
管理
订阅
2022年12月17日
LeetCode刷题记录.Day33
摘要: 对称二叉树 迭代法 class Solution { public: bool isSymmetric(TreeNode* root) { if(root == NULL) return true; queue<TreeNode*> que; que.push(root->left); // 将左子
阅读全文
posted @ 2022-12-17 21:08 凱風快晴
阅读(18)
评论(0)
推荐(0)
2022年12月5日
LeetCode刷题记录.Day32
摘要: 翻转二叉树 递归法 class Solution { public: TreeNode* invertTree(TreeNode* root) { if(root == nullptr) return root; swap(root->left, root->right); //中 invertTr
阅读全文
posted @ 2022-12-05 22:47 凱風快晴
阅读(18)
评论(0)
推荐(0)
2022年12月4日
LeetCode刷题记录.Day31
摘要: 二叉树的层序遍历 递归法 class Solution { public: void order(TreeNode* cur, vector<vector<int>>& result, int depth) { if(cur == nullptr) return; //递归结束条件,指针为空 if(
阅读全文
posted @ 2022-12-04 21:59 凱風快晴
阅读(24)
评论(0)
推荐(0)
2022年12月3日
LeetCode刷题记录.Day30
摘要: 二叉树的前序遍历 递归遍历法 class Solution { public: void traversal(TreeNode* cur, vector<int>& result){ if(cur == NULL) return; //当前节点为空,终止递归过程 result.push_back(c
阅读全文
posted @ 2022-12-03 21:05 凱風快晴
阅读(26)
评论(0)
推荐(0)
2022年11月30日
LeetCode刷题记录.Day29
摘要: 前 K 个高频元素 class Solution { public: // 小顶堆 class mycomparison { public: bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) { return
阅读全文
posted @ 2022-11-30 22:37 凱風快晴
阅读(16)
评论(0)
推荐(0)
2022年11月28日
LeetCode刷题记录.Day28
摘要: 滑动窗口最大值 class Solution { private: class MyQueue{ public: deque<int> que; // 使用双端队列deque来实现单调队列 void pop(int value){ // 每次弹出的时候,比较当前要弹出的数值是否等于队列出口元素的数值
阅读全文
posted @ 2022-11-28 22:25 凱風快晴
阅读(28)
评论(0)
推荐(0)
2022年11月27日
LeetCode刷题记录.Day27
摘要: 逆波兰表达式求值 class Solution { public: int evalRPN(vector<string>& tokens) { stack<long long> st; for(int i = 0; i < tokens.size(); i++){ //检索到运算符号 if(toke
阅读全文
posted @ 2022-11-27 22:27 凱風快晴
阅读(22)
评论(0)
推荐(0)
2022年11月26日
LeetCode刷题记录.Day26
摘要: 删除字符串中所有相邻重复项 1047. 删除字符串中的所有相邻重复项 - 力扣(LeetCode) class Solution { public: string removeDuplicates(string s) { stack<char> st; for(char value : s){ if
阅读全文
posted @ 2022-11-26 22:25 凱風快晴
阅读(9)
评论(0)
推荐(0)
2022年11月24日
LeetCode刷题记录.Day24
摘要: 有效的括号 20. 有效的括号 - 力扣(LeetCode) class Solution { public: bool isValid(string s) { if (s.size() % 2 != 0) return false; //奇数必不符合 stack<char> st; for(int
阅读全文
posted @ 2022-11-24 23:03 凱風快晴
阅读(17)
评论(0)
推荐(0)
2022年11月21日
LeetCode刷题记录.Day22
摘要: 用栈实现队列 232. 用栈实现队列 - 力扣(LeetCode) class MyQueue { public: stack<int> stIn; stack<int> stOut; MyQueue() { } void push(int x) { stIn.push(x); } int pop(
阅读全文
posted @ 2022-11-21 22:40 凱風快晴
阅读(22)
评论(0)
推荐(0)
下一页
公告