Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?2,1,?3,4,?1,2,1,...
分类:
其他好文 时间:
2015-06-25 10:17:54
阅读次数:
133
1. Question求二叉树的最大深度。Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node do...
分类:
其他好文 时间:
2015-06-25 00:00:30
阅读次数:
281
#104 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node...
分类:
其他好文 时间:
2015-06-24 22:38:28
阅读次数:
164
非递归: public static int maxDepth(TreeNode root){ if(root==null) return 0; Queue q=new LinkedList(); q.offer(root); int enQu...
分类:
其他好文 时间:
2015-06-24 12:26:34
阅读次数:
98
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],
the contiguous subarray [2,3] has the largest produ...
分类:
其他好文 时间:
2015-06-23 23:15:40
阅读次数:
144
这里要用到桶排序,感觉不太感兴趣,就直接看了网上的做法。C++中vector中的一些常用函数:取容器中的最大最小值min_element(),max_element()。当有必要对一个接受pair参数的函数传递两个值时, make_pair()尤其显得方便。int minAll = *min_ele...
分类:
其他好文 时间:
2015-06-23 19:57:47
阅读次数:
124
Maximum Subarray: https://leetcode.com/problems/maximum-subarray/
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [...
分类:
其他好文 时间:
2015-06-23 13:40:52
阅读次数:
145
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [?2,1,?3,4,?1,2,1,?5,4],
the contiguous subarray [4,?1,2,1] ha...
分类:
其他好文 时间:
2015-06-23 11:55:55
阅读次数:
176
题目连接http://acm.hdu.edu.cn/showproblem.php?pid=3530SubsequenceDescriptionThere is a sequence of integers. Your task is to find the longest subsequence ...
分类:
其他好文 时间:
2015-06-22 22:02:05
阅读次数:
177
最大子数组的和 在给定的一个数组中,找出连续的一部分数组,使其中的元素和最大。例如输入1,-2,5,3,-3,7,-2,-1,输出的最大子数组和为12。 ①如果什么都不考虑,用最直接的办法来求解,即三重for循环来暴力求结果,该算法的时间复杂度为O(n^3)代码如下://本段代码引自编程之美
int MaxSum(int* A, int n)
{
int maximum = -INF;...
分类:
编程语言 时间:
2015-06-21 15:49:47
阅读次数:
124