码迷,mamicode.com
首页 >  
搜索关键字:动态规划    ( 6061个结果
leetcode 之 Jump Game
Jump Game...
分类:其他好文   时间:2014-09-08 10:53:16    阅读次数:245
57. Jump Game && Jump Game II
方法1: 动态规划。(能走到下标为 n-1 位置时,就结束。) 方法二 : 从前往后跳,每一步长内选择选择能跳到下一步长最远的点。 第一个步长为 0 - A[0], 第二步长为 A[0] - max(0+A[0],..., A[0] + A[A[0]]), 从 0->A[0]->maxA[i...
分类:其他好文   时间:2014-09-08 10:50:56    阅读次数:264
leetcode 之 Best Time to Buy and Sell Stock
Best Time to Buy and Sell Stock  Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie,...
分类:其他好文   时间:2014-09-08 09:39:06    阅读次数:312
动态规划以及在leetcode中的应用
之前只是知道动态规划是通过组合子问题来解决原问题的,但是如何分析,如何应用一直都是一头雾水。最近在leetcode中发现有好几道题都可以用动态规划方法进行解决,就此做下笔录。动态规划:应用于子问题重叠情况,原问题的多个子问题间可能含有相同的子子问题,当然,关于将原问题分解成子问题的思路,分治算法.....
分类:其他好文   时间:2014-09-08 02:08:36    阅读次数:328
Codeforces2B--动态规划(路径DP)
#include #include #include #include #include #include typedef short int int16;///32767typedef int int32;///2147483647typedef long long int64;///922337...
分类:其他好文   时间:2014-09-07 18:28:15    阅读次数:279
动态规划经典问题03:数组中最大的数对差(或最小的数对差)
数组中最大的数对(或最小的数对)...
分类:其他好文   时间:2014-09-07 13:36:05    阅读次数:499
leetcode 之 Scramble String
leetcode 之 Scramble String...
分类:其他好文   时间:2014-09-07 09:50:54    阅读次数:182
leetcode 之 Distinct Subsequences
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 b...
分类:其他好文   时间:2014-09-06 22:37:44    阅读次数:208
leetcode之Word Break
Word Break Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode",...
分类:其他好文   时间:2014-09-06 18:46:33    阅读次数:206
待字闺中之最大乘积分析
原题 一根绳子,长度为n米。将其切成几段,每一段的长度都是整数。请给出一种切法,使得切成的各段绳子之间的乘积是最大的。注意,最少要切一下的。 分析 这个题目如何一步一步的分析呢?不管切几段,总有第一段,第二段…等等。第一段的长度有哪些选择呢?可以是1、2、3...一直到n-1(至少要切一下),我们用max_prod(n)表示长度为n的绳子的切法中,乘积最大的值。那么: 1. 当...
分类:其他好文   时间:2014-09-06 16:08:23    阅读次数:224
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!