03 2024 档案

摘要:98. 验证二叉搜索树 递归 class Solution { TreeNode *leftMost; TreeNode *rightMost; bool limitYourself(TreeNode *root, int min, int max) { if (root == nullptr) { 阅读全文
posted @ 2024-03-13 21:54 joel-q 阅读(2) 评论(0) 推荐(0) 编辑
摘要:小白debug 阅读全文
posted @ 2024-03-12 16:03 joel-q 阅读(1) 评论(0) 推荐(0) 编辑
摘要:1. 两数之和 space: \(O(n)\) time: \(O(n)\) class Solution { using index = pair<int, int>; static bool compare(index a, index b) { return a.second < b.seco 阅读全文
posted @ 2024-03-11 23:57 joel-q 阅读(2) 评论(0) 推荐(0) 编辑
摘要:20. 有效的括号 std::stack<T>的几个方法: top:相当于back pop:相当于pop_back push: 相当于push_back class Solution { public: static char leftOf(char c) { switch (c) { case ' 阅读全文
posted @ 2024-03-09 17:31 joel-q 阅读(3) 评论(0) 推荐(0) 编辑
摘要:三分学 七分练 leetcode 21 合并两个有序链表 尾插法 头结点 #include <iostream> using namespace std; struct ListNode { int val; ListNode *next; ListNode() : val(0), next(nul 阅读全文
posted @ 2024-03-07 21:26 joel-q 阅读(2) 评论(0) 推荐(0) 编辑