<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><linkrel="stylesheet" href="../../../ui/jquery.mobile-1.4.5/jquery.mo..
分类:
Web程序 时间:
2015-02-02 19:59:19
阅读次数:
246
A - Maximum in Table
纯递推。
代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define LL __int64
#define pi acos(-1.0)
const int mod...
分类:
其他好文 时间:
2015-02-02 12:37:06
阅读次数:
135
原题地址二叉树的遍历代码:1 int maxDepth(TreeNode *root) {2 if (!root)3 return 0;4 return max(maxDepth(root->left), maxDepth(root->righ...
分类:
其他好文 时间:
2015-02-02 12:21:50
阅读次数:
132
A. Maximum in Table题意:给定一个表格,它的第一行全为1,第一列全为1,另外的数满足a[i][j]=a[i-1][j]+a[i][j-1],求这个表格中的最大的数a[n][n]即为最大的数#include #include #include #include using n...
分类:
其他好文 时间:
2015-02-01 12:03:20
阅读次数:
275
题目:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complet...
分类:
编程语言 时间:
2015-02-01 10:46:16
阅读次数:
251
Maximum path sum II
Problem 67
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9...
分类:
编程语言 时间:
2015-01-31 13:06:41
阅读次数:
185
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line. 1 import java.util.HashMap; 2 import java.util.Itera...
分类:
其他好文 时间:
2015-01-30 21:04:34
阅读次数:
169
原题地址简单动态规划,跟最大子串和类似。一维状态空间可以经过压缩变成常数空间。代码: 1 int maxProduct(int A[], int n) { 2 if (n = 0; i--) {10 int tmp = minp;11 ...
分类:
其他好文 时间:
2015-01-30 10:36:58
阅读次数:
179
Say you have an array for which the ith element isthe price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as manytransactions as you like (ie, buy one an...
分类:
其他好文 时间:
2015-01-30 09:11:13
阅读次数:
176
Given a binary tree, findits maximum depth.
The maximum depth is thenumber of nodes along the longest path from the root node down to the farthestleaf node.
可用递归,效率低。
这里用类似层次遍历的算法。设置一个队列和两个int变量...
分类:
其他好文 时间:
2015-01-30 09:10:56
阅读次数:
261