会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Luke's Blog.
欲穷千里目,事后拂衣归
博客园
首页
新随笔
联系
订阅
管理
2022年4月8日
面试经典题:二叉树最近公共祖先
摘要: 二叉树的最近公共祖先 面试经典题:最近公共祖先,提供三种思路: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
阅读(38)
评论(0)
推荐(0)
2022年4月5日
面试经典题:TOP-K问题(附快排+堆排C++实现)
摘要: 数组中的第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
阅读(58)
评论(0)
推荐(0)
2022年2月22日
目标检测面试-nms
摘要: 1、python语言下: def nms(self, dets, scores): # 这一代码来源于Faster RCNN项目 """"Pure Python NMS baseline.""" x1 = dets[:, 0] #xmin y1 = dets[:, 1] #ymin x2 = det
阅读全文
posted @ 2022-02-22 23:49 SrtFrmGNU
阅读(106)
评论(0)
推荐(0)
2022年2月14日
LeetCode题解-07(简单图论)
摘要: LeetCode题解 chap-17:图论 1、岛屿数量 // 并查集+坐标变换 class UnionFind{ public: vector<int> parent; UnionFind(int n){ for(int i=0;i<n;i++) parent.push_back(i); } in
阅读全文
posted @ 2022-02-14 01:25 SrtFrmGNU
阅读(48)
评论(0)
推荐(0)
LeetCode题解-05(搜索、贪心)
摘要: LeetCode题解 chap-13:搜索 section13-1: DFS 1、电话号码的字母组合 class Solution { public: vector<string> dict = {"","","abc","def","ghi","jkl","mno", "pqrs","tuv","
阅读全文
posted @ 2022-02-14 01:24 SrtFrmGNU
阅读(32)
评论(0)
推荐(0)
LeetCode题解-06(分治、动态规划)
摘要: LeetCode题解 chap-15:分治 1、不同的二叉搜索树 II【卡特兰数】 class Solution { public: vector<TreeNode*> generateTrees(int n) { return dfs(1,n); } vector<TreeNode*> dfs(i
阅读全文
posted @ 2022-02-14 01:24 SrtFrmGNU
阅读(61)
评论(0)
推荐(0)
LeetCode题解-04(位运算、排序、数学)
摘要: LeetCode题解 chap-10:位运算 1、二进制求和 class Solution { public: string addBinary(string a, string b) { reverse(a.begin(), a.end()); reverse(b.begin(), b.end()
阅读全文
posted @ 2022-02-14 01:23 SrtFrmGNU
阅读(35)
评论(0)
推荐(0)
LeetCode题解-03(栈、队列、双指针、哈希表)
摘要: LeetCode题解 chap-7: 栈、队列 1、最小栈【设计】 class MinStack { public: stack<int> a,b; /** initialize your data structure here. */ MinStack() { } void push(int va
阅读全文
posted @ 2022-02-14 01:21 SrtFrmGNU
阅读(54)
评论(0)
推荐(0)
LeetCode题解-02(树、字典树、堆)
摘要: LeetCode题解 chap-4: 树 1、验证二叉搜索树 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode
阅读全文
posted @ 2022-02-14 01:18 SrtFrmGNU
阅读(50)
评论(0)
推荐(0)
LeetCode题解-01(二分、链表、数组)
摘要: LeetCode题解 chap-1: 二分 section1-1: 索引二分 1、搜索旋转排序数组 根据中点划分为两段有序性队列,使用二分可在logN复杂度下实现查找; class Solution { public: int search(vector<int>& nums, int target
阅读全文
posted @ 2022-02-14 01:04 SrtFrmGNU
阅读(50)
评论(0)
推荐(0)
下一页
公告