会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Uitachi
fresh coder
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
11
12
13
14
15
16
17
18
19
下一页
2021年1月13日
LeetCode872. 叶子相似的树
摘要: 题目 1 class Solution { 2 public: 3 vector<int>ans1; 4 vector<int>ans2; 5 bool leafSimilar(TreeNode* root1, TreeNode* root2) { 6 dfs(root1,ans1); 7 dfs(
阅读全文
posted @ 2021-01-13 15:16 Uitachi
阅读(70)
评论(0)
推荐(0)
2021年1月12日
LeetCode783. 二叉搜索树节点最小距离
摘要: 题目 和LeetCode530没什么区别 1 class Solution { 2 public: 3 vector<int>ans; 4 int minDiffInBST(TreeNode* root) { 5 int min = INT_MAX;dfs(root); 6 for(int i =
阅读全文
posted @ 2021-01-12 17:37 Uitachi
阅读(88)
评论(0)
推荐(0)
LeetCode700. 二叉搜索树中的搜索
摘要: 题目 代码 简单递归 1 class Solution { 2 public: 3 TreeNode* searchBST(TreeNode* root, int val) { 4 if(!root) return NULL; 5 TreeNode* p; 6 if(root->val == val
阅读全文
posted @ 2021-01-12 17:18 Uitachi
阅读(72)
评论(0)
推荐(0)
LeetCode671. 二叉树中第二小的节点
摘要: 题目 纯暴力 1 class Solution { 2 public: 3 vector<int>ans; 4 int findSecondMinimumValue(TreeNode* root) { 5 dfs(root); 6 sort(ans.begin(),ans.end()); 7 int
阅读全文
posted @ 2021-01-12 16:49 Uitachi
阅读(68)
评论(0)
推荐(0)
2021年1月11日
LeetCode653. 两数之和 IV - 输入 BST
摘要: 题目 直接暴力 1 class Solution { 2 public: 3 vector<int>ans; 4 bool findTarget(TreeNode* root, int k) { 5 dfs(root); 6 for(int i = 0;i <ans.size();i++) 7 fo
阅读全文
posted @ 2021-01-11 17:00 Uitachi
阅读(73)
评论(0)
推荐(0)
机器学习2-7
摘要: 2014年斯坦福机器学习课程2-7 课程中主要介绍梯度下降算法找代价函数的最小值。我们知道梯度下降可以找到局部最优, 但不一定是全局最优。但如果convex function(凸函数),可以通过梯度下降找到全局最优解。 此时局部最优对应全局最优。于是恩达老师举了个凸函数的例子,弓形的曲面。但并没有具
阅读全文
posted @ 2021-01-11 16:28 Uitachi
阅读(177)
评论(0)
推荐(0)
LeetCode637. 二叉树的层平均值
摘要: 题目 1 class Solution { 2 public: 3 vector<double>ans; 4 vector<double> averageOfLevels(TreeNode* root) { 5 if(!root) return ans; 6 queue<TreeNode*>q; 7
阅读全文
posted @ 2021-01-11 16:08 Uitachi
阅读(87)
评论(0)
推荐(0)
LeetCode617. 合并二叉树
摘要: 题目 1 class Solution { 2 public: 3 TreeNode* mergeTrees(TreeNode* t1, TreeNode* t2) { 4 if(!t1 && !t2) return NULL; 5 if(t1 == NULL&& t2 != NULL) retur
阅读全文
posted @ 2021-01-11 11:53 Uitachi
阅读(72)
评论(0)
推荐(0)
2021年1月10日
LeetCode590. N叉树的后序遍历
摘要: 题目 1 class Solution { 2 public: 3 vector<int>ans; 4 vector<int> postorder(Node* root) { 5 dfs(root); 6 return ans; 7 } 8 void dfs(Node* root){ 9 if(ro
阅读全文
posted @ 2021-01-10 18:12 Uitachi
阅读(81)
评论(0)
推荐(0)
LeetCode589. N叉树的前序遍历
摘要: 题目 法一、递归 1 class Solution { 2 public: 3 vector<int>ans; 4 void dfs(Node* root){ 5 if(root!=NULL){ 6 ans.push_back(root->val); 7 for(int i = 0;i < root
阅读全文
posted @ 2021-01-10 17:56 Uitachi
阅读(79)
评论(0)
推荐(0)
上一页
1
···
11
12
13
14
15
16
17
18
19
下一页
公告