
leetcode-dp
文章平均质量分 77
shanshanhi
这个作者很懒,什么都没留下…
展开
-
120. Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle [ [2], [3,4], [6,5,原创 2017-02-28 17:38:35 · 248 阅读 · 0 评论 -
将数组分成两部分,使得这两部分的和的差最小
将一个数组分成两部分,不要求两部分所包含的元素个数相等,要求使得这两个部分的和的差值最小。比如对于数组{1,0,1,7,2,4},可以分成{1,0,1,2,4}和{7},使得这两部分的差值最小。思路:这个问题可以转化为求数组的一个子集,使得这个子集中的元素的和尽可能接近sum/2,其中sum为数组中所有元素的和。这样转换之后这个问题就很类似0-1背包问题了:在n件物品中找到m件转载 2017-03-28 17:35:32 · 26859 阅读 · 3 评论 -
494. Target Sum 和 416. Partition Equal Subset Sum
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out原创 2017-03-10 11:00:26 · 428 阅读 · 0 评论 -
免费陷阱的问题--动态规划
免费馅饼Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28835 Accepted Submission(s): 9848Problem Description都 说天上不会掉馅饼,但有一天g转载 2017-03-28 15:30:42 · 757 阅读 · 0 评论 -
413. Arithmetic Slices(Arithmetic:算术算法,slices:片)
A 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 sequenc转载 2017-02-24 19:08:25 · 280 阅读 · 0 评论 -
(待整理)300. Longest Increasing Subsequence
300. Longest Increasing SubsequenceGiven an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest inc原创 2017-01-07 12:01:11 · 331 阅读 · 0 评论 -
115. 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 (can转载 2017-03-02 16:39:36 · 499 阅读 · 0 评论 -
338. Counting Bits 和191. Number of 1 Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you sh原创 2017-02-24 18:36:29 · 326 阅读 · 0 评论 -
72. Edit Distance
编辑距离概念描述:编辑距离,又称Levenshtein距离,是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。例如将kitten一字转成sitting:sitten (k→s)sittin (e→i)sitting (→g)俄罗斯科学家Vladimir Levenshtein在1965年提出这个概念。 问题:找出字符...原创 2017-03-02 13:57:42 · 270 阅读 · 0 评论 -
5. 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 longest palindromic substring.分析:采用中转载 2017-03-02 17:14:46 · 407 阅读 · 0 评论