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 depth of the two subtrees of every node never differ ...
分类:
其他好文 时间:
2015-03-12 20:51:39
阅读次数:
108
题意:给出一颗二叉树的前序遍历和中序遍历,输出其后续遍历首先知道中序遍历是左子树根右子树递归遍历的,所以只要找到根节点,就能够拆分出左右子树前序遍历是按照根左子树右子树递归遍历的,那么可以找出这颗树的根节点,然后拆分出左右子树,对左右子树进行相同的操作,也就是将建树的这个函数递归调用下去build函...
分类:
其他好文 时间:
2015-03-12 20:44:23
阅读次数:
132
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:
其他好文 时间:
2015-03-12 16:45:35
阅读次数:
117
题目:Reverse BitsReverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010...
分类:
其他好文 时间:
2015-03-12 14:57:14
阅读次数:
125
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-03-12 12:48:57
阅读次数:
95
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
For example, the 32-bit integer ’11' has binary representation 00000000...
分类:
其他好文 时间:
2015-03-12 11:34:16
阅读次数:
112
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010...
分类:
其他好文 时间:
2015-03-12 11:29:01
阅读次数:
120
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
114 Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ 2 5
...
分类:
其他好文 时间:
2015-03-12 09:55:58
阅读次数:
110
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
107 Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level ...
分类:
其他好文 时间:
2015-03-12 09:55:46
阅读次数:
117
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
102 Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For exam...
分类:
其他好文 时间:
2015-03-12 09:55:01
阅读次数:
128