The problem:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.My analysis:The recursion is the best way...
分类:
其他好文 时间:
2015-01-08 00:49:30
阅读次数:
265
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep...
分类:
其他好文 时间:
2015-01-08 00:45:25
阅读次数:
257
https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/http://blog.csdn.net/linhuanmars/article/details/22969069/**
*Definitionforbinarytree
*publicclassTreeNode{
*intval;
*TreeNodeleft;
*TreeNoderight;
*TreeNode(intx){val=x;}
*}
*/
publicclassSoluti..
分类:
其他好文 时间:
2015-01-07 19:14:02
阅读次数:
158
Given a binary tree containing digits from 0-9 only,
each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which
represents the number 123.
Find the total ...
分类:
编程语言 时间:
2015-01-07 16:59:46
阅读次数:
149
准备: ① re-sign.jar重签名工具:(下载地址为:http://troido.de/downloads/category/1); ② 待重签名的apk;重签名步骤: ① 右键re-sign.jar,在“打开方式”里,选择“Java(TM) Platform SE binary”选项,...
分类:
编程语言 时间:
2015-01-07 16:36:24
阅读次数:
207
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-01-07 16:21:35
阅读次数:
143
classTestL
{
publicstaticvoidmain(String[]args)
{
inti=60;
Stringbinary=Integer.toBinaryString(i);
System.out.println(binary);
Stringhex=Integer.toHexString(i);
System.out.println(hex);
intj=i&15;
Stringk1=(i<=9)?j+"":(char)(j-10+..
分类:
其他好文 时间:
2015-01-07 15:09:56
阅读次数:
130
Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol...
分类:
其他好文 时间:
2015-01-07 14:40:01
阅读次数:
173
一、概述序列化是把对象转变成流。相反的过程就是反序列化。哪些场合用到这项技术呢?1. 把对象保存到本地,下次运行程序时恢复这个对象。2. 把对象传送到网络的另一台终端上,然后在此终端还原这个对象。3. 复制系统的粘帖板中,然后用快捷键Ctrl+V恢复这个对象。常用的序列化流有Binary(二进制流)...
原题如下;
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
题意很简单:根据中序遍历和后序遍历的序列生成树
思路很简单:根据后序遍历的序列确定根节点,在中序遍历中找到根节点,将原来的序列分为左右两个部分,递归解决左右两个部分就可以解决这个问题。
Java代码如下:
publ...
分类:
其他好文 时间:
2015-01-07 01:52:25
阅读次数:
160