Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3...
分类:
其他好文 时间:
2015-10-03 18:17:43
阅读次数:
161
Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened ...
分类:
其他好文 时间:
2015-10-03 18:17:01
阅读次数:
176
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-10-03 18:16:44
阅读次数:
200
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,...
分类:
其他好文 时间:
2015-10-03 18:13:25
阅读次数:
214
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.struct ListNode { int val; ListNode *...
分类:
其他好文 时间:
2015-10-03 15:30:38
阅读次数:
152
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:使用二分法,将list的中间节点作为根节点,然后分别处理list左半边及右半边,以此递归。struc...
分类:
其他好文 时间:
2015-10-03 14:24:21
阅读次数:
162
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
分类:
其他好文 时间:
2015-10-03 11:53:52
阅读次数:
134
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-10-03 11:50:06
阅读次数:
131
1、题目名称 Path Sum(树的根节点到叶节点的数字之和) 2、题目地址 https://leetcode.com/problems/path-sum/ 3、题目内容 英文:Given a binary tree and a sum, determine if the tree has a root-to-leaf p...
分类:
其他好文 时间:
2015-10-02 00:20:20
阅读次数:
316
Problem DescriptionLet L denote the number of 1s in integer D’s binary representation. Given two integers S1 and S2, we call D a WYH number if S1≤L≤S2...
分类:
其他好文 时间:
2015-10-01 19:07:20
阅读次数:
142