
动态规划
hjiam2
渴望成为一名码农,爱生活,爱运动,爱编程
展开
-
【Leetcode】Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:原创 2013-11-28 19:01:32 · 763 阅读 · 0 评论 -
动态规划--钢条切割的C++实现
在《算法导论》动态规划那章,讲述了一个应用动态规划的例子--钢条切割。 钢条切割的问题是这样的:给定一段长度为n英寸的钢条和一个价格表(i=1,2,...,10),求切割钢条方案,使得销售收益最大。 我们可以采用一种简单的递归求解方法:我们将钢条从左边切割下长度为i的一段,只对右边剩下的 长度为n-i的一段继续进行切割(递归求解),对左边的一段则不再进行切割。用公式可以表示为: 方法一:带备原创 2013-11-14 17:09:42 · 4198 阅读 · 0 评论 -
【Leetcode】Best Time to Buy and Sell Stock III
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 complete at most two transactions. Note: You may原创 2013-12-15 17:46:18 · 2202 阅读 · 2 评论