码迷,mamicode.com
首页 >  
搜索关键字:refresh    ( 1347个结果
LeetCode – Refresh – Binary Tree Upside Down
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
LeetCode – Refresh – Binary Tree Level Order Traversal
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
LeetCode – Refresh – Binary Tree Pre Order Traversal
Same with inorder.1. recursive: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeN...
分类:其他好文   时间:2015-03-18 08:58:05    阅读次数:131
LeetCode – Refresh – Binary Tree Post Order Traversal
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
LeetCode – Refresh – Binary Tree Level Order Traversal ii
This question is almost same as the previous one.I just use a stack (another vector) of vector to store the level result. Then reverse it. 1 /** 2 * ....
分类:其他好文   时间:2015-03-18 08:56:41    阅读次数:155
LeetCode – Refresh – Binary Tree Maximum Path Sum
Use lMax get the maximum value of a sub SINGLE branch (left branch or right branch or just current node).Use gMax get the maximum value of the whole s...
分类:其他好文   时间:2015-03-18 08:56:01    阅读次数:190
LeetCode – Refresh – Binary Tree Iterator
It is similar to use stack for BST inorder traversal.So do the same thing :1. Get stack to store right branchs(include current node).2. When you pop t...
分类:其他好文   时间:2015-03-18 07:50:34    阅读次数:139
LeetCode – Refresh – Balanced Binary Tree
Need a helper function to return the binary tree maximum height. If the return value is -1, it means there is a imbalanced subbranch . 1 /** 2 * Defi....
分类:其他好文   时间:2015-03-18 07:47:44    阅读次数:123
LeetCode – Refresh – Anagrams
Use a hash table to record it. The tricky part is that when the hash value is > 0, it is the index + 1. Otherwise, that string already exists in resul...
分类:其他好文   时间:2015-03-18 07:47:38    阅读次数:100
LeetCode – Refresh – Best Time to Buy and Sell Stock ii
This is simple, use greedy algorithm will solve the problem. 1 class Solution { 2 public: 3 int maxProfit(vector &prices) { 4 int len = pr...
分类:其他好文   时间:2015-03-18 07:46:55    阅读次数:155
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!