2015年5月13日

摘要: Title: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Title: Given a singly linked list where eleme 阅读全文
posted @ 2015-05-13 16:33 月下之风 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Title: Given preorder and inorder traversal of a tree, construct the binary tree. 使用递归构建。 Title: Given inorder and postorder traversal of a tree, cons 阅读全文
posted @ 2015-05-13 16:30 月下之风 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Title: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary 阅读全文
posted @ 2015-05-13 16:29 月下之风 阅读(170) 评论(0) 推荐(0) 编辑

2015年5月12日

摘要: Title: 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 阅读全文
posted @ 2015-05-12 14:46 月下之风 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Title: Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. 思路:使用中序遍历得到这个序列,找出其中的逆序的两个进 阅读全文
posted @ 2015-05-12 13:33 月下之风 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Title: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: (1) The left subtree of a node co 阅读全文
posted @ 2015-05-12 10:33 月下之风 阅读(175) 评论(0) 推荐(0) 编辑

2015年5月10日

摘要: Title: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 uniq 阅读全文
posted @ 2015-05-10 18:49 月下之风 阅读(203) 评论(0) 推荐(0) 编辑

2015年5月8日

摘要: 二叉树是一种非常重要的数据结构,很多其它数据结构都是基于二叉树的基础演变而来的。对于二叉树,有前序、中序以及后序三种遍历方法。因为树的定义本身就是递归定义,因此采用递归的方法去实现树的三种遍历不仅容易理解而且代码很简洁。而对于树的遍历若采用非递归的方法,就要采用栈去模拟实现。在三种遍历中,前序和中序 阅读全文
posted @ 2015-05-08 14:42 月下之风 阅读(202) 评论(0) 推荐(0) 编辑

2015年5月7日

摘要: Title: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", ret 阅读全文
posted @ 2015-05-07 15:38 月下之风 阅读(221) 评论(0) 推荐(0) 编辑

2015年5月6日

摘要: Title: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2 阅读全文
posted @ 2015-05-06 11:02 月下之风 阅读(116) 评论(0) 推荐(0) 编辑

导航