Validate Binary Search Tree
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 nodes with...
分类:
其他好文 时间:
2015-08-07 13:21:02
阅读次数:
92
题目:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]....
分类:
其他好文 时间:
2015-08-07 10:56:38
阅读次数:
112
【101-Symmetric Tree(对称树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetr...
分类:
编程语言 时间:
2015-08-07 08:19:16
阅读次数:
163
【096-Unique Binary Search Trees(唯一二叉搜索树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?
For example,
Given n = 3, t...
分类:
编程语言 时间:
2015-08-07 08:18:59
阅读次数:
172
【100-Same Tree(两棵树是否相同)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structural...
分类:
编程语言 时间:
2015-08-07 08:18:10
阅读次数:
185
1020. Tree Traversals (25)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequenc...
分类:
其他好文 时间:
2015-08-07 01:49:17
阅读次数:
113
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Solution:二进制加法,和为2进1,和为3进1留1; 1 class Solution ...
分类:
其他好文 时间:
2015-08-07 00:22:07
阅读次数:
354
4.6 Write an algorithm to find the'next'node (i.e., in-order successor) of a given node in a binary search tree. You may assume that each node has a l...
分类:
其他好文 时间:
2015-08-07 00:10:52
阅读次数:
112
Co-prime
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2263 Accepted Submission(s): 847
Problem Description
Given a number N, ...
分类:
其他好文 时间:
2015-08-06 20:35:27
阅读次数:
116
题目描述e.给出一个二叉树,求其最短路径长度,最短路径定义长度:从根节点到最近的叶子节点的路径上的节点个数。...
分类:
编程语言 时间:
2015-08-06 18:34:12
阅读次数:
118