码迷,mamicode.com
首页 >  
搜索关键字:binary tree maximum    ( 26821个结果
leetcode -day14 Populating Next Right Pointers in Each Node I II
1、 ?? Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate...
分类:其他好文   时间:2014-05-15 04:57:36    阅读次数:221
LeetCode--Same Tree
Same Tree  Total Accepted: 16072 Total Submissions: 38790My Submissions Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal i...
分类:其他好文   时间:2014-05-15 04:00:39    阅读次数:319
LeetCode之Unique Binary Search Trees
Unique Binary Search Trees, Given n, how many structurally unique BST's (binary search trees) that store values 1...n?...
分类:其他好文   时间:2014-05-15 02:32:11    阅读次数:245
[leetcode]_Maximum Depth of Binary Tree
第三道树的题目,我还是不会,我擦,怎么递归算法还是不能很好理解。看来还得好好研究下递归算法。题目:求一棵树的最大深度。思路:递归地求取左子树最大深度 和 右子树最大深度,返回较大值即为 整棵树的 最大深度。代码:public int maxDepth(TreeNode root) { ...
分类:其他好文   时间:2014-05-14 23:07:14    阅读次数:373
Pat(Advanced Level)Practice--1043(Is It a Binary Search Tree)
Pat1043代码题目描述:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contain...
分类:其他好文   时间:2014-05-14 22:03:25    阅读次数:487
Leetcode 动态规划 Maximum Subarray
题意:最大连续子序列和,在一个数组中找到和最大的连续子数组 思路:dp, 对于第i个数,有两种选择:把它加入在子数组里,不加入子数组(子数组到此结束) 加不加入子数组,要比较它加入前后子数组的总和是变大了还是变小了,如果变大则加入,变小则不加入 所以,我们需要记录以i-1结尾的子数组的总和,最后的结果在这些总和中取最大的那个 f[i] = max(f[i-1]+a[i],f[i-1]); max({f[i]}) 实现时用两个变量,一个保存f[i-1],一个保存目前为止最大的f[i] 复杂度:时间O(n),空...
分类:其他好文   时间:2014-05-14 21:53:14    阅读次数:250
Zoj 3201 Tree of Tree
Zoj 3201 Tree of Tree...
分类:其他好文   时间:2014-05-14 21:44:57    阅读次数:250
LeetCode--Binary Tree Preorder Traversal
Binary Tree Preorder Traversal  Total Accepted: 18022 Total Submissions: 51784My Submissions Given a binary tree, return the preorder traversal of its nodes' values. For example: Given b...
分类:其他好文   时间:2014-05-14 20:43:22    阅读次数:242
HDU 4786 Fibonacci Tree
点击打开链接 Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 975    Accepted Submission(s): 289 Problem Description  ...
分类:其他好文   时间:2014-05-14 20:18:47    阅读次数:366
Best Time to Buy and Sell Stock III
Total Accepted: 8400 Total Submissions: 38235 My Submissions Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profi...
分类:其他好文   时间:2014-05-14 19:39:53    阅读次数:275
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!