摘要: 144. 二叉树的前序遍历 详解 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), l 阅读全文
posted @ 2023-08-22 16:03 zqh2023 阅读(272) 评论(0) 推荐(0)
摘要: https://zhuanlan.zhihu.com/p/503464361 https://blog.csdn.net/weixin_57761086/article/details/126802156 阅读全文
posted @ 2023-08-22 14:31 zqh2023 阅读(9) 评论(0) 推荐(0)
摘要: 239. 滑动窗口最大值 详解 // 队列que是STL的双向队列deque // 队列存放的是元素在序列中的序号 //参考https://www.jianshu.com/p/e59d51e1eef5 class Solution { public: vector<int> maxSlidingWi 阅读全文
posted @ 2023-08-22 14:18 zqh2023 阅读(45) 评论(0) 推荐(0)
摘要: 一文彻底弄懂单调栈及双单调栈 https://www.zhihu.com/question/485257774/answer/2375650870 单调队列 阅读全文
posted @ 2023-08-22 10:24 zqh2023 阅读(8) 评论(0) 推荐(0)
摘要: 20. 有效的括号 详解 class Solution { public: bool isValid(string s) { //最里面一对是相邻闭合 stack<char> stack_1; for(int i=0; i< s.length(); i++){ if(s[i] == '(' || s 阅读全文
posted @ 2023-08-21 16:11 zqh2023 阅读(282) 评论(0) 推荐(0)
摘要: 232. 用栈实现队列 详解 class MyQueue { public: stack<int> st_in; stack<int> st_out; MyQueue() { } void push(int x) { st_in.push(x); } int pop() { if(st_out.em 阅读全文
posted @ 2023-08-18 16:38 zqh2023 阅读(360) 评论(0) 推荐(0)
摘要: 344. 反转字符串 详解 class Solution { public: void reverseString(vector<char>& s) { int left = 0; int right = s.size() - 1; while(left <= right){ // char tmp 阅读全文
posted @ 2023-08-16 17:34 zqh2023 阅读(434) 评论(0) 推荐(0)
摘要: 454. 四数相加 II 讲解 class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) { //map unor 阅读全文
posted @ 2023-08-16 16:33 zqh2023 阅读(399) 评论(0) 推荐(0)
摘要: 242. 有效的字母异位词 讲解 class Solution { public: bool isAnagram(string s, string t) { if(s.length() != t.length()) return false; map<char, int> map_s; map<ch 阅读全文
posted @ 2023-08-15 11:03 zqh2023 阅读(473) 评论(0) 推荐(0)
摘要: https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html 阅读全文
posted @ 2023-08-14 17:39 zqh2023 阅读(12) 评论(0) 推荐(0)