题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and s...
分类:
其他好文 时间:
2016-01-10 14:13:53
阅读次数:
144
题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:转化为数组,更容易搜寻中点package bst;class List...
分类:
其他好文 时间:
2016-01-10 13:03:04
阅读次数:
121
题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the de...
分类:
其他好文 时间:
2016-01-10 12:58:28
阅读次数:
116
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:总是取中间点为rootpackage bst;public class ConvertSort...
分类:
其他好文 时间:
2016-01-10 12:55:55
阅读次数:
105
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:递归,preord...
分类:
其他好文 时间:
2016-01-10 11:44:45
阅读次数:
156
题目: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 a...
分类:
其他好文 时间:
2016-01-10 11:40:19
阅读次数:
129
题目: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 tree...
分类:
其他好文 时间:
2016-01-10 11:37:16
阅读次数:
130
题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / ...
分类:
其他好文 时间:
2016-01-10 11:34:47
阅读次数:
142
题目: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...
分类:
其他好文 时间:
2016-01-10 10:28:58
阅读次数:
144
题目大意:平面上有n个点,两两不同。现在给出二叉树的定义,要求树边一定是从上指向下,即从y坐标大的点指向小的点,并且每个结点至多有两个儿子。现在让你求给出的这些点是否能构成一棵二叉树,如果能,使二叉树的树边长度(欧几里德长度)总和最小,输出这个总和。如果不能,输出-1.答案与标准答案相差1e-6内都...
分类:
其他好文 时间:
2016-01-10 08:10:59
阅读次数:
277