题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and ....
分类:
编程语言 时间:
2014-07-31 05:22:15
阅读次数:
287
/*A + B Problem II
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an...
分类:
其他好文 时间:
2014-07-30 17:38:54
阅读次数:
306
/*
A + B Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 209912 Accepted Submission(s): 40404
Problem Description
I have a...
分类:
其他好文 时间:
2014-07-30 17:32:24
阅读次数:
226
题目描述:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra spac...
分类:
其他好文 时间:
2014-07-30 17:18:44
阅读次数:
204
题目: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 profit. You may com....
分类:
编程语言 时间:
2014-07-30 05:35:03
阅读次数:
309
题目:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all suc....
分类:
编程语言 时间:
2014-07-30 03:19:32
阅读次数:
341
给一个矩阵,依然是求满足条件的最大子矩阵不过题目中说任意两列可以交换,这是对题目的简化求出h数组以后直接排序,然后找出(col-j)*h[j]的最大值即可(这里的j是从0开始)因为排序会影响到h数组下一行的求解,所以将h数组中的元素复制到temp数组中去,再排序 1 //#define LOCAL ...
分类:
移动开发 时间:
2014-07-30 00:40:22
阅读次数:
232
[LeetCode]Binary Tree Level Order Traversal II...
分类:
其他好文 时间:
2014-07-29 14:42:48
阅读次数:
145
HDU 2830 Matrix Swapping II (最大完全子矩阵之可移动列)...
分类:
移动开发 时间:
2014-07-29 14:36:08
阅读次数:
236
其实每一行的结果是二项式展开的系数,但是考虑到当给定的参数过大的时候,在求组合的过程中会出现溢出(中间过程要用到乘法),但是这样的算法的时间复杂度是O(N),所以在参数不太大的时候,还是不错的。
这里用迭代的方法来求,当然复杂度就高了,是O(N^2),这里主要说下迭代时候的技巧,即在一个列表(数组)里进行迭代,实现如此的操作,要求在求下一行的时候,要从后往前进行,若是从前向后,就把后面要用的变量...
分类:
编程语言 时间:
2014-07-29 14:35:28
阅读次数:
452