上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页
摘要: 对于一个含有n个数的有序数组1~N,能够产生多少种不同结果的二叉搜素树BST? 如何生成这些不同结构的BST? 有序数组如何生成平衡二叉搜索树? 1 class Solution { 2 public: 3 int numTrees(int n) { 4 int* dp = new int[n+1]; 5 dp[0] = 1; 6 ... 阅读全文
posted @ 2017-05-17 10:23 wxquare 阅读(589) 评论(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 阅读全文
posted @ 2017-05-16 23:19 wxquare 阅读(389) 评论(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 @ 2017-05-16 22:44 wxquare 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 参考:http://blog.csdn.net/njdragonfly/article/details/6373199 阅读全文
posted @ 2017-05-15 23:20 wxquare 阅读(314) 评论(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 @ 2017-05-15 22:57 wxquare 阅读(1703) 评论(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 @ 2017-05-15 22:50 wxquare 阅读(626) 评论(0) 推荐(0) 编辑
摘要: 用递归方法计算二叉树的最大、最小深度,注意他们之间的区别 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the roo 阅读全文
posted @ 2017-05-15 22:21 wxquare 阅读(1494) 评论(0) 推荐(0) 编辑
摘要: 二叉树的构建必须要有中序遍历,另外还需要前序和后续中的一种。下面分别是有前序和中序、后续和中序采用递归方法构建二叉树的过程 阅读全文
posted @ 2017-05-15 21:04 wxquare 阅读(303) 评论(0) 推荐(0) 编辑
摘要: binary-tree-level-order-traversal binary-tree-level-order-traversal-ii binary-tree-zigzag-level-order-traversal /** * Definition for binary tree * struct TreeNode { * int val; * TreeNod... 阅读全文
posted @ 2017-05-14 23:27 wxquare 阅读(371) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Given an array where elements are sorted 阅读全文
posted @ 2017-05-14 21:50 wxquare 阅读(673) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页