
Dynamic Programming
文章平均质量分 53
Arcome
这个作者很懒,什么都没留下…
展开
-
LeetCode #312 - Burst Balloons - Hard
ProblemGiven n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get n原创 2016-11-02 17:23:45 · 493 阅读 · 0 评论 -
LeetCode #377 - Combination Sum IV - Medium
ProblemGiven an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Examplenums = [1, 2, 3]target = 4The poss原创 2016-11-03 09:40:05 · 368 阅读 · 0 评论 -
LeetCode #392 - Is Subsequence - Medium
ProblemGiven a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) str原创 2016-11-01 23:39:19 · 411 阅读 · 0 评论 -
LeetCode #413 - Arithmetic Slices - Medium
ProblemA sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic原创 2016-11-01 23:22:46 · 623 阅读 · 0 评论 -
LeetCode #357 - Count Numbers with Unique Digits - Medium
ProblemGiven a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Hint:A direct way is to use the backtracking approach.Backtracking should contains three states whic原创 2016-11-02 08:10:05 · 397 阅读 · 0 评论 -
LeetCode #343 - Integer Break - Medium
ProblemGiven a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.Note: You may assume that n原创 2016-11-02 08:49:43 · 371 阅读 · 0 评论 -
LeetCode #279 - Perfect Squares - Medium
ProblemGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Examplegiven n = 12, return 3 because 12 = 4 + 4 + 4; given n =原创 2016-12-11 11:53:24 · 404 阅读 · 0 评论 -
2017.1.10 算法测试题集 - 1005 - 最大间隔和
Problem给定一组整数,要求只能间隔地取数出来,试问取出来的数最大和是多少?ExampleA={1,2,3};Return 4A={3,1,1,2};Return 5;Algorithm典型的动态规划问题。 列状态转移方程:设sum[i]表示前i个数的最大间隔和,要求sum[i],则有两种情况。若选第i个数,则sum[i]=sum[i-2]+nums[i]若不选第i个数,则sum[原创 2017-01-13 17:13:43 · 701 阅读 · 0 评论 -
2017.1.10 算法测试题集 - 1006 - 编辑距离问题
Problem给定两个字符串s和t,要求给出由s编辑到t的最小步数。编辑方式有三种,每次只能对一个字母或一个字母位置进行操作:1. 插入,如 snowy->sunnowy2. 删除,如 snowy->snwy3. 替换,如 snowy->snonyExamples= "snowy"t= "sunny"Return 3Algorithm编辑距离问题,是《算法概论》中在动态规划一节举的例原创 2017-01-13 17:15:19 · 715 阅读 · 0 评论