Depth-first Search
文章平均质量分 65
candy_crush
胡编乱写
展开
-
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-09-17 16:34:06 · 183 阅读 · 0 评论 -
Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3原创 2016-09-17 18:07:50 · 254 阅读 · 0 评论 -
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. 求二叉树的最短深度 解法一:深度优先遍历DFS /**原创 2016-09-17 22:34:43 · 186 阅读 · 0 评论 -
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. 求二叉树的最大深度,采用深度优先遍历原则 /** * Def原创 2016-09-17 21:52:08 · 321 阅读 · 0 评论 -
Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe原创 2016-09-18 10:43:31 · 286 阅读 · 0 评论 -
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. For example: Given the below binary tree and sum原创 2016-09-18 11:26:05 · 207 阅读 · 0 评论