摘要:
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 = 22, 5 / \ 4 8 / / \ 11 13 4 / \... 阅读全文
posted @ 2013-04-14 14:04
冰点猎手
阅读(140)
评论(0)
推荐(0)
摘要:
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 binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val... 阅读全文
posted @ 2013-04-14 13:33
冰点猎手
阅读(181)
评论(0)
推荐(0)
摘要:
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. /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val... 阅读全文
posted @ 2013-04-14 13:23
冰点猎手
阅读(129)
评论(0)
推荐(0)
摘要:
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree. /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right... 阅读全文
posted @ 2013-04-14 13:18
冰点猎手
阅读(136)
评论(0)
推荐(0)
摘要:
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree. /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(... 阅读全文
posted @ 2013-04-14 12:09
冰点猎手
阅读(159)
评论(0)
推荐(0)
摘要:
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its zigzag level order traversal as:[ [3... 阅读全文
posted @ 2013-04-14 10:35
冰点猎手
阅读(157)
评论(0)
推荐(0)

浙公网安备 33010602011771号