摘要:
669.修剪二叉搜索树 题目链接 文章讲解 视频讲解 class Solution { public: TreeNode* trimBST(TreeNode* root, int low, int high) { if(root == nullptr) return nullptr; // 当前值小 阅读全文
posted @ 2024-06-03 21:35
深蓝von
阅读(24)
评论(0)
推荐(0)
摘要:
235.二叉搜索树的最近公共祖先 题目链接 文章讲解 视频讲解 思路:递归遍历二叉搜索树 如果当前值大于p和q的值,向左遍历 如果当前值小于p和q的值,向右遍历 否则说明当前值介于p和q之间,直接返回当前节点 class Solution { public: TreeNode* lowestComm 阅读全文
posted @ 2024-06-03 14:05
深蓝von
阅读(13)
评论(0)
推荐(0)

浙公网安备 33010602011771号