积少成多

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2016年6月26日

摘要: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 利用:中序+后序遍历 c 阅读全文
posted @ 2016-06-26 22:50 x7b5g 阅读(144) 评论(0) 推荐(0) 编辑

摘要: Given preorder and inorder traversal of a tree, construct the binary tree. 基本功: 利用前序和中序构建二叉树 , code 阅读全文
posted @ 2016-06-26 22:46 x7b5g 阅读(218) 评论(0) 推荐(0) 编辑

摘要: Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, ex 阅读全文
posted @ 2016-06-26 22:44 x7b5g 阅读(171) 评论(0) 推荐(0) 编辑

摘要: Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa 阅读全文
posted @ 2016-06-26 22:24 x7b5g 阅读(140) 评论(0) 推荐(0) 编辑

摘要: Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: 思路: 将一个二叉树 就地 压成"链表"的结构; 阅读全文
posted @ 2016-06-26 22:20 x7b5g 阅读(135) 评论(0) 推荐(0) 编辑

摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 升序数组a[],构造平衡二叉树,左右子树高度差不超过1. 思路: 利用先序构建二叉树的方法,将数组的中间 阅读全文
posted @ 2016-06-26 21:57 x7b5g 阅读(143) 评论(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 阅读全文
posted @ 2016-06-26 21:44 x7b5g 阅读(200) 评论(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 i 阅读全文
posted @ 2016-06-26 21:37 x7b5g 阅读(489) 评论(0) 推荐(0) 编辑

摘要: 笔记另写: code: 前序线索化 阅读全文
posted @ 2016-06-26 21:16 x7b5g 阅读(484) 评论(0) 推荐(0) 编辑

摘要: Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
posted @ 2016-06-26 21:14 x7b5g 阅读(224) 评论(0) 推荐(0) 编辑

摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2016-06-26 21:01 x7b5g 阅读(169) 评论(0) 推荐(0) 编辑

摘要: Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2016-06-26 20:37 x7b5g 阅读(194) 评论(0) 推荐(0) 编辑

摘要: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文
posted @ 2016-06-26 20:01 x7b5g 阅读(122) 评论(0) 推荐(0) 编辑

摘要: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2016-06-26 19:50 x7b5g 阅读(144) 评论(0) 推荐(0) 编辑

摘要: Description: Count the number of prime numbers less than a non-negative number, n. 找质数的问题. [http://www.cnblogs.com/li-daphne/p/5549557.html]我在这里有过分析 ! 阅读全文
posted @ 2016-06-26 19:27 x7b5g 阅读(148) 评论(0) 推荐(0) 编辑