![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
二叉树
lyh_xd
一匹正在努力提高算法、编程水平的机器学习马
展开
-
Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two原创 2016-05-26 16:11:00 · 240 阅读 · 0 评论 -
Leetcode 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.原创 2016-05-24 09:04:59 · 216 阅读 · 0 评论 -
Leetcode 100. Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 树结构常用递归算法、原创 2016-05-23 21:33:49 · 201 阅读 · 0 评论 -
leetcode 110. Balanced Binary Tree
判断一个二叉树是否是 height-balaced 的二叉树,height-balaced 二叉树的定义是:任一结点的左右子树高度差不超过1.原创 2016-04-13 00:13:24 · 253 阅读 · 0 评论 -
Leetcode 257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are: [“1->2->5”, “1->3”]用深度优先搜索+递归处理/** * Definition f原创 2016-09-01 10:21:04 · 215 阅读 · 0 评论 -
Leetcode 230. Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST is mod原创 2016-06-29 22:05:42 · 263 阅读 · 0 评论 -
Leetcode 337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour,原创 2016-06-17 10:28:59 · 233 阅读 · 0 评论 -
Leetcode 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node./** * Definition for a binary tree node.原创 2016-05-29 17:11:37 · 227 阅读 · 0 评论 -
Leetcode 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.原创 2016-05-29 15:34:03 · 215 阅读 · 0 评论 -
Leetcode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric:1/ \ 2 2 / \ / \ 3 4 4 3 But the following is not:原创 2016-05-27 11:50:24 · 235 阅读 · 0 评论 -
Leetcode 226. Invert Binary Tree
Invert a binary tree. 题目意思是将二叉树每层的左右孩子交换。原创 2016-05-24 14:30:42 · 230 阅读 · 0 评论