码迷,mamicode.com
首页 >  
搜索关键字:maximum subsequence    ( 5146个结果
LeetCode - Best Time to Buy and Sell 3
这道题在前两个的基础上做稍微改进就可以。下面是AC代码: 1 /** 2 * Design an algorithm to find the maximum profit. You may complete at most two transactions. 3 * @pa...
分类:其他好文   时间:2014-07-22 23:01:13    阅读次数:251
[leetcode] Best Time to Buy and Sell Stock II
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 complete a...
分类:其他好文   时间:2014-05-06 00:51:29    阅读次数:353
Leetcode: Maximum Depth of Binary Tree
1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNo...
分类:其他好文   时间:2014-05-05 22:44:13    阅读次数:328
UVA 10405 Longest Common Subsequence
最长公共子系列,简单的dp,不过注意有空格,所以,在读字符串的时候,尽量用gets读,这样基本没问题#include#include#include#includeusing namespace std;int dp[1001][1001];int MAX(int x,int y){ if (...
分类:其他好文   时间:2014-05-04 11:34:41    阅读次数:294
[leetcode] Best Time to Buy and Sell Stock III
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 complete a...
分类:其他好文   时间:2014-05-03 23:21:20    阅读次数:292
Distinct Subsequences
题目: Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (c...
分类:其他好文   时间:2014-05-03 21:48:19    阅读次数:252
ORA-01925:maximum of 80 enabled roles exceeded
ORA-01925:maximum of 80 enabled roles exceeded...
分类:其他好文   时间:2014-05-03 15:55:33    阅读次数:296
LeetCode5:Longest Palindromic Substring
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo...
分类:其他好文   时间:2014-05-01 20:07:13    阅读次数:429
LeetCode OJ - Binary Tree Maximum Path
这道题需要注意的地方有以下一些:1. 求从子树中的某节点到当前节点的最大路径不能采用递归方法,因为这个部分会被反复的调用,如果用递归,会使得之前已经计算过的节点被重复计算,使得时间复杂度特别高;2. 树中有节点的值是负数的。下面是AC代码。(我发现AC并不代表代码真的完全正确!!) 1 /** 2 ...
分类:其他好文   时间:2014-05-01 12:10:52    阅读次数:274
POJ 2533 Longest Ordered Subsequence 最长上升子序列
最长上升子序列: 有两种基本方法:两个时间复杂度分别为O(n^2)和O(nlogn)。 O(n^2) 容易的出动态规划的递推公式dp[i]=max(dp[j])+1 j=1,2...i-1,dp[i]是以元素i结尾的最长子序列个数。 在O(n^2)的最长上升子序列中可以通过记录每个元素前缀元素位置的方式来得到整个的最长上升子序列。 代码:int LISOn2(int a[],int to...
分类:其他好文   时间:2014-04-29 13:24:22    阅读次数:314
5146条   上一页 1 ... 512 513 514 515 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!