码迷,mamicode.com
首页 >  
搜索关键字:maximum sum subarray    ( 25087个结果
leetcode——Two Sum 两数之和(AC)
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe...
分类:其他好文   时间:2014-06-09 23:14:45    阅读次数:264
LeetCode: Triangle [120]
【题目】 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to...
分类:其他好文   时间:2014-06-08 17:52:45    阅读次数:235
LeetCode之Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum....
分类:其他好文   时间:2014-06-08 15:54:08    阅读次数:258
Light OJ 1278 Sum of Consecutive Integers N拆分成连续整数和
题目来源:Light OJ 1278 Sum of Consecutive Integers 题意:N拆分成连续整数和的方案数 思路:奇因数的个数 #include #include #include #include using namespace std; //筛素数 const int maxn = 10000010; bool vis[maxn]; int prime[10...
分类:其他好文   时间:2014-06-08 15:34:09    阅读次数:295
LeetCode: Best Time to Buy and Sell Stock [121]
【题目】 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit. ...
分类:其他好文   时间:2014-06-08 15:11:58    阅读次数:298
2-SAT模版
const int maxn = 100010; int n, m; vector G[maxn*2]; bool mark[maxn*2]; int S[maxn*2], c; int a[maxn], b[maxn], sum; bool dfs(int x) { if(mark[x^1]) return false; if(mark[x]) return true; mark...
分类:其他好文   时间:2014-06-08 10:31:01    阅读次数:198
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. 方法 使用DFS对树进行遍...
分类:其他好文   时间:2014-06-08 10:26:33    阅读次数:207
poj 2139 Six Degrees of Cowvin Bacon , floyd
点击打开链接 题意:给定牛的关系图,求其中一头牛与其他牛关系路程之和sum最小,然后输出 sum*100/(n-1) floyd求任意两点间的最短路程 注意: inf不能太大,因为 f[i][k] + f[k][j]  做加法时可能会溢出! #include #include const int maxn = 300 + 5; const int inf = 1<<29; int...
分类:其他好文   时间:2014-06-08 05:07:03    阅读次数:181
HDU1002--A + B Problem II
HDU1002--A + B Problem II...
分类:其他好文   时间:2014-06-08 04:56:06    阅读次数:242
[LeetCode] Two Sum [17]
题目 :Input: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2 解题思路: 给出一个数组合一个数,如果两个数的和等于所给的数,求出该两个数所在数组中的位置。 这个题也挺常见的,就是两个指针,从前后两个方向扫描。但是本题有以下几个需要的点: 1. 所给数组不是有序的; 2. 返回的下标是从1开始的,并且是原来无序数组中的下标; 3. 输入数组中可能含有重复的元素。 好了,把以上三点想到的话,做这个题应该不会有啥问题。 具体方法:把原...
分类:其他好文   时间:2014-06-08 02:14:06    阅读次数:250
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!