摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.N... 阅读全文
posted @ 2015-08-03 15:44 尾巴草 阅读(228) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,... 阅读全文
posted @ 2015-08-03 10:55 尾巴草 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 题目:给定一个字符串,问最少插入多少字符,使字符串变成回文字符串。思路:X:原字符串 Y:逆字符串 需要插入的字符数=X的长度-(X与Y的LCS的长度) 这里使用了滚动数组,压缩空间,原因:d[i][j]只依赖于 d[i-1][j] d[i][j-1] 1 #include 2 #include... 阅读全文
posted @ 2015-08-03 10:25 尾巴草 阅读(383) 评论(0) 推荐(0) 编辑