摘要: '?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input stri... 阅读全文
posted @ 2014-11-15 06:17 LiBlog 阅读(269) 评论(0) 推荐(0) 编辑
摘要: Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].Anaylsis:Me... 阅读全文
posted @ 2014-11-14 11:05 LiBlog 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initial... 阅读全文
posted @ 2014-11-14 10:39 LiBlog 阅读(143) 评论(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 is ... 阅读全文
posted @ 2014-11-09 07:03 LiBlog 阅读(192) 评论(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 only n... 阅读全文
posted @ 2014-11-09 06:01 LiBlog 阅读(237) 评论(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 an... 阅读全文
posted @ 2014-11-09 05:42 LiBlog 阅读(123) 评论(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: But the fol 阅读全文
posted @ 2014-11-09 05:36 LiBlog 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Solution: 1 /** 2 * Definition for binary tree 3 * public class TreeNode ... 阅读全文
posted @ 2014-11-09 02:06 LiBlog 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For ... 阅读全文
posted @ 2014-11-09 00:45 LiBlog 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for binary tree 3 * ... 阅读全文
posted @ 2014-11-09 00:31 LiBlog 阅读(228) 评论(0) 推荐(0) 编辑