04 2022 档案

摘要:二叉树的最近公共祖先 面试经典题:最近公共祖先,提供三种思路:1、模拟路径,2、dfs,3、dfs优化 class Solution { public: bool dfs(TreeNode* root, TreeNode* t, vector<TreeNode*>&path){ if(!root) 阅读全文
posted @ 2022-04-08 23:36 SrtFrmGNU 阅读(34) 评论(0) 推荐(0) 编辑
摘要:数组中的第K个最大元素 [TOP-k问题] // 1、采用快选 class Solution { public: int quick_sort(vector<int>& nums,int l,int r,int k){ if(l>=r) return nums[k]; int a = l-1, b 阅读全文
posted @ 2022-04-05 16:31 SrtFrmGNU 阅读(53) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示