摘要: There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. Yo 阅读全文
posted @ 2017-01-30 06:19 CodesKiller 阅读(193) 评论(0) 推荐(0) 编辑
摘要: There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certai 阅读全文
posted @ 2017-01-30 05:21 CodesKiller 阅读(133) 评论(0) 推荐(0) 编辑
摘要: The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文
posted @ 2017-01-30 05:02 CodesKiller 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so tha 阅读全文
posted @ 2017-01-30 03:12 CodesKiller 阅读(146) 评论(0) 推荐(0) 编辑
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2017-01-29 13:24 CodesKiller 阅读(103) 评论(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 @ 2017-01-29 12:45 CodesKiller 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 区别:动态规划全局最优解中一定包含某个局部最优解,但不一定包含前一个局部最优解,因此需要记录之前的所有最优解。条件:最优子结构;重叠子问题。方法:自底向上构造子问题的解。例子:子序列最大和问题,滑雪问题 贪心算法条件:每一步的最优解一定依赖上一步的最优解。方法:从问题的某一个初始解出发逐步逼近给定的 阅读全文
posted @ 2017-01-29 12:29 CodesKiller 阅读(682) 评论(0) 推荐(1) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t 阅读全文
posted @ 2017-01-29 12:21 CodesKiller 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 概述:动态规划在查找有很多重叠子问题的情况的最优解时有效。他将问题重新组合成子问题。为了避免多次解决这些子问题,他们的结果都逐渐被计算并被保存。因此,动态规划保存递归时的结果,因而不会在解决同样的问题时花费时间。 动态规划只能应用于最优子结构问题,最优子结构的意思是局部最优解能决定全局最优解(对有些 阅读全文
posted @ 2017-01-29 11:21 CodesKiller 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except  阅读全文
posted @ 2017-01-29 06:30 CodesKiller 阅读(124) 评论(0) 推荐(0) 编辑