Similar to the sorted array. But we have to remember, the position of node not depends on the index. So we need do two more things:1. Ensure the point...
分类:
其他好文 时间:
2015-03-19 06:20:30
阅读次数:
132
Only different with preorder and postorder is that the root start from the beginning for preorder. 1 /** 2 * Definition for binary tree 3 * struct T.....
分类:
其他好文 时间:
2015-03-19 06:20:26
阅读次数:
122
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 00000000000000000000000000001011, so the function should return...
分类:
其他好文 时间:
2015-03-18 18:06:47
阅读次数:
92
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-03-18 15:20:00
阅读次数:
131
先序遍历:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), ...
分类:
其他好文 时间:
2015-03-18 13:48:17
阅读次数:
124
题目:Maple treesTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 177 Accepted Submission(s): 63 Problem DescriptionThere are a lot of trees in HDU. Ki...
分类:
其他好文 时间:
2015-03-18 12:21:11
阅读次数:
222
Made a stupid bug....... When reverse the vector, stop it at mid. Otherwise, it will swap back......Mark!!!!!!!! 1 /** 2 * Definition for binary tree....
分类:
其他好文 时间:
2015-03-18 10:23:29
阅读次数:
120
Recursive method can be unstand easily:1. Assume we get the sub node with this transition. So we need to make the current node.2. As the symmetic, the...
分类:
其他好文 时间:
2015-03-18 10:12:06
阅读次数:
128
Basic question. Use a queue to store Node, use two numbers to record current level node numbers and next level node numbers. 1 /** 2 * Definition for....
分类:
其他好文 时间:
2015-03-18 08:58:27
阅读次数:
105
Still 3 methods:Same with inorder, but post order is a little different. We need to treat it as reverse result of preorder.So we go to right branch fi...
分类:
其他好文 时间:
2015-03-18 08:57:58
阅读次数:
132