明白了上一题是求最大的连续子数组之和后,这题就更加简单了,遇到小于0的就不要加。
public class Solution {
public int maxProfit(int[] prices) {
if(prices.length < 2)
return 0;
int n = prices.length;
...
分类:
其他好文 时间:
2014-10-19 00:05:52
阅读次数:
194
本文讲解4道关于permutation的题目。
1. Permutation:输出permutation——基础递归
2. Permutation Sequence: 输出第k个permutation——推理
3. Next Permutation:给定一个permutation中的序列,求字典序它的下一个permutation是什么——逻辑推理
4. Permutation II:和第一题有细微的差别: 对于一个可能有重复元素的数组输出所有permutation——有条件dfs...
分类:
其他好文 时间:
2014-10-18 19:45:40
阅读次数:
224
大模拟:枚举6个方向,检查每个0能否移动
Puzzle
Time Limit: 2 Seconds Memory Limit: 65536 KB
Little Georgie likes puzzles very much. Recently he has found a wooden triangle in the box with old toys. The...
分类:
其他好文 时间:
2014-10-18 18:25:06
阅读次数:
311
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2014-10-18 05:23:21
阅读次数:
275
Problem Description
Given an N * M matrix with each entry equal to 0 or 1. We can find some rectangles in the matrix whose entries are all 1, and we define the maximum area of such rectangle as this ...
分类:
移动开发 时间:
2014-10-17 23:26:50
阅读次数:
264
1、将tri初始化为[1],当rowIndex=0时,return的结果是:1,而题目要求应该是:[1],故将tri初始化为[[1]],返回结果设置为tri[0]即可满足要求;2、最开始第二层循环是从1到i进行遍历,这样就不好控制数据的更新,因为更新第j个数据要用到原tri行的第j-1个数据,而此时...
分类:
其他好文 时间:
2014-10-17 21:55:39
阅读次数:
264
Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(...
分类:
其他好文 时间:
2014-10-17 18:24:18
阅读次数:
285
Inside Deep Zoom –Part II: Mathematical AnalysisWelcome to part two ofInside Deep Zoom. Inpart one, I talked about the very basic ideas behind Deep Zo...
分类:
Web程序 时间:
2014-10-17 13:45:51
阅读次数:
263
[leetcode]Given n, generate all structurally unique BST's (binary search trees) that store values 1...n....
分类:
其他好文 时间:
2014-10-17 12:08:07
阅读次数:
165
最新版管道应力分析CAESAR II 2014 v7.00 WinXP_7 凯撒2CAESAR II 2013 R1 v6.10 管道设计应力分析 新增功能CAESAR Ⅱ 2011 v5.30.2 WinXP_7-ISO 1DVD(最新完全破解版,适用于Win7 32位和64位系统。管道应力分析....