
leetcode
h4329201
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode之partition-list
题目如下:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each原创 2017-10-14 15:40:22 · 232 阅读 · 0 评论 -
LEETCODE解题记录——对称二叉树
题目要求: 给定一个二叉树,检查它是否是镜像对称的。 例如,二叉树 [1,2,2,3,4,4,3] 是对称的。 1 / \ 2 2 / \ / \ 3 4 4 3 但是下面这个原创 2018-04-19 16:38:01 · 270 阅读 · 0 评论 -
LEETCODE解题记录——二叉树的最大深度
给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶节点的最长路径上的节点数。 解析: 题目的意思十分简单,就是求二叉树的树高。我们只需要从根节点开始依次向下搜索,并且每个节点保存以此节点为根节点的子树的树高,最后递归即可。代码如下所示:int maxDepth(TreeNode* root) { if (!root) return 0; ret原创 2018-04-19 17:09:45 · 399 阅读 · 0 评论 -
LEETCODE解题记录——按层输出二叉树
给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问所有节点)。 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层次遍历结果: [ [3], [9,20...原创 2018-04-19 20:33:19 · 1744 阅读 · 0 评论