摘要: 题目:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the or... 阅读全文
posted @ 2014-06-07 10:01 ThreeMonkey 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains onl... 阅读全文
posted @ 2014-05-19 17:30 ThreeMonkey 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space ... 阅读全文
posted @ 2014-05-19 17:28 ThreeMonkey 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目: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... 阅读全文
posted @ 2014-05-19 17:18 ThreeMonkey 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 题目: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 / ... 阅读全文
posted @ 2014-05-14 17:20 ThreeMonkey 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,... 阅读全文
posted @ 2014-05-14 17:13 ThreeMonkey 阅读(143) 评论(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... 阅读全文
posted @ 2014-05-14 17:11 ThreeMonkey 阅读(168) 评论(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... 阅读全文
posted @ 2014-05-14 17:09 ThreeMonkey 阅读(137) 评论(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.解题思路:前序遍历序列的... 阅读全文
posted @ 2014-05-14 17:07 ThreeMonkey 阅读(166) 评论(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.解题思路:后序遍历的最... 阅读全文
posted @ 2014-05-14 17:05 ThreeMonkey 阅读(132) 评论(0) 推荐(0) 编辑