2018年1月24日

leetcode 119 Pascal's Triangle II

摘要: 求Pascal三角的某一层,要求O(n)复杂度。 阅读全文

posted @ 2018-01-24 23:13 willaty 阅读(108) 评论(0) 推荐(0) 编辑

leetcode 118 Pascal's Triangle

摘要: 给定一整数,求Pascal三角形。 阅读全文

posted @ 2018-01-24 22:45 willaty 阅读(100) 评论(0) 推荐(0) 编辑

leetcode 112 Path Sum

摘要: 给定一棵二叉树和一个整数,求是否存在一条从根节点到叶节点,其数值等于整数。 阅读全文

posted @ 2018-01-24 22:43 willaty 阅读(91) 评论(0) 推荐(0) 编辑

leetcode 111 Minimum Depth of Binary Tree

摘要: 求二叉树最小深度。 递归非常简单,见最大深度。 这里用BFS。 阅读全文

posted @ 2018-01-24 14:26 willaty 阅读(101) 评论(0) 推荐(0) 编辑

leetcode 110 Balanced Binary Tree

摘要: 判断是否平衡二叉树。 中间多了个判断,剪枝。 阅读全文

posted @ 2018-01-24 13:35 willaty 阅读(98) 评论(0) 推荐(0) 编辑

leetcode 108 Convert Sorted Array to Binary Search Tree

摘要: 给定一个有序的数组,生成平衡二叉树。 阅读全文

posted @ 2018-01-24 01:48 willaty 阅读(77) 评论(0) 推荐(0) 编辑

leetcode 107 Binary Tree Level Order Traversal II

摘要: 给定二叉树,从左到右遍历每层,在从下到上遍历。 解决: BFS 由于数据量大,move增速明显。 DFS 阅读全文

posted @ 2018-01-24 01:19 willaty 阅读(106) 评论(0) 推荐(0) 编辑

leetcode 104 Maximum Depth of Binary Tree

摘要: int maxDepth(TreeNode* root) { if (!root == NULL) return 0; return max(maxDepth(root->left), maxDepth(root->right)) + 1; } 阅读全文

posted @ 2018-01-24 00:34 willaty 阅读(75) 评论(0) 推荐(0) 编辑

leetcode 101 Symmetric Tree

摘要: 判定两棵树是否严格镜像对称。 解决: BFS DFS 阅读全文

posted @ 2018-01-24 00:30 willaty 阅读(99) 评论(0) 推荐(0) 编辑

导航