07 2025 档案
摘要:617. 合并二叉树 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nu
        阅读全文
                
摘要:112. 路径总和 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nul
        阅读全文
                
摘要:110. 平衡二叉树 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nu
        阅读全文
                
摘要:226. 翻转二叉树 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nu
        阅读全文
                
摘要:二叉树的递归遍历 前序 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(n
        阅读全文
                
摘要:98. 所有可达路径 #include <iostream> #include <list> #include <vector> using namespace std; vector<vector<int>> result; vector<int> path; void dfs(vector<li
        阅读全文
                
摘要:151. 反转字符串中的单词 class Solution { public: void reverse(string& s, int start, int end){ //翻转,区间写法:左闭右闭 [] for (int i = start, j = end; i < j; i++, j--) {
        阅读全文
                
摘要:344. 反转字符串 class Solution { public: void reverseString(vector<char>& s) { int n = s.size(); cout << n; int count = 0; while(count < n / 2) { char tmp 
        阅读全文
                
摘要:24. 两两交换链表中的节点 class Solution { public: ListNode* swapPairs(ListNode* head) { ListNode * dummy_head = new ListNode(0); dummy_head->next = head; if(hea
        阅读全文
                
摘要:203. 移除链表元素 虚拟头指针统一: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {}
        阅读全文
                
摘要:150. 逆波兰表达式求值 class Solution { public: int evalRPN(vector<string>& tokens) { stack<long long> st; for(int i = 0; i < tokens.size(); i++) { if(tokens[i
        阅读全文
                
摘要:454. 四数相加 II class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) { int result = 
        阅读全文
                
摘要:哈希表: 哈希碰撞 拉链法 线性探测法 常见的三种哈希结构 242. 有效的字母异位词 只有字母,可以用长度为26的定长数组表示。 class Solution { public: bool isAnagram(string s, string t) { array<int, 26> cnt_s{}
        阅读全文
                
摘要:42. 接雨水 class Solution { public: int trap(vector<int>& height) { int n = height.size(); stack<int> st; st.push(0); int answer = 0; for(int i = 1; i < 
        阅读全文
                
                    
                
浙公网安备 33010602011771号