题目:输入一个整型数组,数组里有正数也有负数。数组中一个或者连续的多个整数组成一个子数组。求所有子数组的和的最大值。要求时间复杂度为O(n)分析:首先需要考虑的条件:数组里有正数也有负数,根据这个条件,从数组第一个元素开始,temp累计相加,当temp增加时,我们就将temp赋值给sum。当temp...
分类:
其他好文 时间:
2014-07-07 23:22:47
阅读次数:
224
微软近期Open的职位:Job Description:Do you want to play a key part in building a multi-billion dollar revenue product for Microsoft? Are you passionate about ...
分类:
其他好文 时间:
2014-07-07 19:44:16
阅读次数:
322
Problem Description: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 equ...
分类:
其他好文 时间:
2014-07-07 19:03:39
阅读次数:
165
一直格式错误,不想改了,没A 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 int T,K=0;10 scanf("%d",&T);11 ...
分类:
其他好文 时间:
2014-06-30 14:01:05
阅读次数:
188
Fortran has two kinds of subprograms: subroutine and function. Usually, subroutine is a combination of several procedures generating side effects with...
分类:
其他好文 时间:
2014-06-30 12:43:00
阅读次数:
207
微软近期Open的职位:Job Title:Software Development EngineerIIDivision: Server & Tools Business - Commerce Platform GroupWork Location: Shanghai, ChinaAre you ...
分类:
其他好文 时间:
2014-06-30 11:24:01
阅读次数:
255
【问题】
Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
定义一个过程,它以三个数为参数,返回其中较大的两个数的平方和。
【普通版】
(define (sum-square-largest x y ...
分类:
其他好文 时间:
2014-06-30 00:19:52
阅读次数:
270
【题目】
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Follow up:
Can you solve it without using extra space?
【题意】
给定一个单向链表,如果链表有环,则返回环开始的位置。
【思路】
仍然是维护两个指针, p1, p2, p1每次走一步, p2每次走两步
...
分类:
其他好文 时间:
2014-06-29 23:59:21
阅读次数:
354
这题没想出来,直接参考了nocow,太弱了= =。
基本思想是动态规划,因为树是递归结构,所以可以递归分成子问题处理。一个树可以看成根加左子树加右子树,所以根据乘法原理,N个节点放成k层的结构等于i个节点放成k - 1层乘以N - i - 1个节点放在k - 1层的积。
令dp[i][j] 为i个节点放j层的最多可能数量,则dp[i][j] = sum{dp[k][j - 1] * dp[i ...
分类:
其他好文 时间:
2014-06-29 23:49:12
阅读次数:
339
变量和数值相关,它储存了那个值,有了变量就可以储存操作数据了。js与其他语言不同,它是非类型的。就是变量可以存放任何类型的值,而其他语言需要存放特定类型的值。var i=5;i="fdsfad";这是合法的。变量的声明一般是由VAR 关键字声明的var i,sum; //一次声明两个变量, 若变量....
分类:
Web程序 时间:
2014-06-29 19:28:32
阅读次数:
153