上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 50 下一页
摘要: 求路径和,仅需要一直减去当前节点的数字,然后看看在根结点的时候是否为0,如果不是返回false就行啦 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNod 阅读全文
posted @ 2020-02-07 05:19 SteveYu 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 我们要想知道最小深度,我们只需要知道根结点在的层级吖。这样思考是不是很方便。把每个根结点的层级加入map,取map的第一位,就是最小深度啦 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo 阅读全文
posted @ 2020-02-07 04:58 SteveYu 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 判断平衡树的经典教科书办法:左右紫薯差小于等于1。 我们仅仅需要进行判断平衡,左右子树差小于等于1,继续返回左子树平衡且右子树平衡。 否则返回false /** * Definition for a binary tree node. * struct TreeNode { * int val; * 阅读全文
posted @ 2020-02-07 04:32 SteveYu 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 顺序数组建树,要从中间开始建树。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val( 阅读全文
posted @ 2020-02-07 03:58 SteveYu 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 中序遍历,常规操作 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), lef 阅读全文
posted @ 2020-02-07 03:33 SteveYu 阅读(88) 评论(0) 推荐(0) 编辑
摘要: c++比Binary Tree Level Order Traversal 多了一行reverse函数 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNo 阅读全文
posted @ 2020-02-07 03:22 SteveYu 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 二叉树的层序遍历,直接进行用二维vector进行层序,用一个queue进行,记录大小后,进行不断push进去。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * Tr 阅读全文
posted @ 2020-02-07 03:12 SteveYu 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 求树的最大深度,如果树为空,则返回0否则返回左最大深度和右最大深度的最大值,进行加一 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right 阅读全文
posted @ 2020-02-07 02:43 SteveYu 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
posted @ 2020-02-07 02:37 SteveYu 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
posted @ 2020-02-07 02:13 SteveYu 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1.一元线性回归与损失函数 在我们解决一元线性回归进行拟合曲线的时候,常常会使用梯度下降法。 假设我们的数据集为 我们想将其拟合成一条曲线,然后进行训练。拟合曲线表示如下 我们如何去拟合呢?显然两点确定一条直线的。我们就其次,然后求得一个函数,各个点到该函数的方差和最小,于是,我们将其称为损失函数( 阅读全文
posted @ 2020-02-07 01:11 SteveYu 阅读(1468) 评论(0) 推荐(0) 编辑
摘要: Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol ValueI 1V 5X 10L 50C 100D 500M 1000For example, two is writt 阅读全文
posted @ 2020-02-06 19:36 SteveYu 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121Output: true 阅读全文
posted @ 2020-02-06 18:58 SteveYu 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123Output: 321Example 2: Input: -123Output: -321Example 3: Input: 120Ou 阅读全文
posted @ 2020-02-06 18:42 SteveYu 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minut 阅读全文
posted @ 2020-02-06 16:59 SteveYu 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 50 下一页