递归public class Solution { public ArrayList preorderTraversal(TreeNode root) { ArrayList res = new ArrayList(); traversal(root, res); ...
分类:
其他好文 时间:
2015-05-21 07:51:52
阅读次数:
113
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解题思路:给出一个二叉树的中...
分类:
其他好文 时间:
2015-05-21 06:40:31
阅读次数:
121
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解题思路:给出一个二叉树的先序...
分类:
其他好文 时间:
2015-05-21 06:37:42
阅读次数:
96
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:用一个有序数组,创建一个平衡二叉查找树。为确保平衡,需要满足两子树的高度差不大于1,可以通过设置...
分类:
其他好文 时间:
2015-05-21 06:37:05
阅读次数:
123
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-05-21 06:36:41
阅读次数:
103
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node. ...
分类:
其他好文 时间:
2015-05-21 00:05:17
阅读次数:
181
解题思路:中序遍历,左子树-根节点-右子树JAVA实现如下: public List inorderTraversal(TreeNode root) { List list = new ArrayList(); if(root==null) r...
分类:
编程语言 时间:
2015-05-20 23:56:04
阅读次数:
174
Tree Traversals AgainAn inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node ...
分类:
其他好文 时间:
2015-05-20 21:51:18
阅读次数:
110
Given a BST, find 2 nodes in it which sum to a given targethint:Inorder traversal + BST + 2 SUM* Time : O(N)* Space: O(lgN) 1 class TreeNode0 { 2 ...
分类:
其他好文 时间:
2015-05-20 13:03:34
阅读次数:
188
命名规则交叉编译工具链的命名规则为:arch [-vendor] [-os] [-(gnu)eabi]arch – 体系架构,如ARM,MIPSvendor – 工具链提供商os – 目标操作系统eabi – 嵌入式应用二进制接口(Embedded Application Binary Interf...
分类:
其他好文 时间:
2015-05-20 12:47:23
阅读次数:
106