摘要: 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 an... 阅读全文
posted @ 2015-01-18 22:12 vincently 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2015-01-18 16:51 vincently 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2015-01-18 13:59 vincently 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文
posted @ 2015-01-18 12:50 vincently 阅读(213) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文
posted @ 2015-01-17 21:08 vincently 阅读(318) 评论(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. 1 /** 2 * De... 阅读全文
posted @ 2015-01-17 19:25 vincently 阅读(215) 评论(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. 1 /** 2 * Def... 阅读全文
posted @ 2015-01-17 15:47 vincently 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-01-17 13:10 vincently 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 首先定义二叉树的存储结构: 1 struct TreeNode {2 int val;3 TreeNode *left;4 TreeNode *right;5 6 TreeNode(int v, TreeNode* l = NULL, TreeNode *r = N... 阅读全文
posted @ 2015-01-17 11:23 vincently 阅读(2788) 评论(0) 推荐(0) 编辑
摘要: iven a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exam... 阅读全文
posted @ 2015-01-16 21:09 vincently 阅读(223) 评论(0) 推荐(0) 编辑