Ood Three sum to zero Add two number linked list Recursive way iterative way Bfs traversal. Corner cases Ood Tiny URL Behavior 14 amazon behavior prin ...
分类:
其他好文 时间:
2018-08-30 11:02:38
阅读次数:
162
leetcode上刷到一题中序遍历一颗二叉树的题,两种方法,使用递归或者栈 原题及解答:https://leetcode.com/problems/binary-tree-inorder-traversal/discuss/164579/recursion-and-stack-solve-the-p ...
分类:
Web程序 时间:
2018-08-30 02:07:15
阅读次数:
220
inorder traversal 的问题,可以递归做也可以非递归做。 这道题和 426. Convert Binary Search Tree to Sort Doubly Linked List 类似,需要一个 prev 指针记录前一个节点。非递归更好些,递归写可以把 prev 声明为全局变量, ...
分类:
其他好文 时间:
2018-08-30 02:03:51
阅读次数:
162
Construct Binary Tree from Preorder and Inorder Traversal /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode lef... ...
分类:
其他好文 时间:
2018-08-28 21:13:50
阅读次数:
176
题目链接 https://leetcode cn.com/problems/binary tree postorder traversal/description/ 题目描述 给定一个二叉树,返回它的 后序 遍历。 示例: 进阶: 递归算法很简单,你可以通过迭代算法完成吗? 题解 后序遍历,使用一个 ...
分类:
其他好文 时间:
2018-08-27 14:50:54
阅读次数:
163
树里的 divide and conquer 感觉和 post order traversal 就是一个东西,反正都是递归。 下面方法返回了 root ,也可以不返回,直接用 flatten 自己递归也行。 时间复杂度 O(nlogn) 空间复杂度 O(h) ...
分类:
其他好文 时间:
2018-08-26 01:10:35
阅读次数:
121
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
分类:
其他好文 时间:
2018-08-24 21:46:35
阅读次数:
197
[抄题]: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For ex ...
分类:
编程语言 时间:
2018-08-24 00:39:40
阅读次数:
136
1 #include 2 #include 3 4 typedef struct TreeNode{ 5 int value; 6 struct TreeNode* Left; 7 struct TreeNode* Right; 8 }TreeNode; 9 10 void printTree(Tr... ...
分类:
其他好文 时间:
2018-08-22 19:33:19
阅读次数:
304
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
分类:
其他好文 时间:
2018-08-19 15:46:04
阅读次数:
139