随笔分类 -  dp 1

70. Climbing Stairs
摘要:口起灵,比那个稍微难点,一次不是跳两级,是跳k级,给一个k,一个n,n是总台阶数,k是每次最多跳的个数,可以比它少。我一上来说dp,给了个时间复杂度 O(kn),空间O(n)的。他说能不能简化一下空间。我说那我给了个时间kn, 空间k的。最后讨论了一阵子我简化成了时间n,空间min(n,k)的。就是不用每次都把那k个加一遍,保持一个sum就好了,每次删除一个旧的再加一个新的。 You a... 阅读全文

posted @ 2018-11-09 06:50 猪猪🐷

45. Jump Game II
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to ... 阅读全文

posted @ 2018-11-06 07:34 猪猪🐷

343. Integer Break
摘要:343. Integer Break Given 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. Example 1: ... 阅读全文

posted @ 2018-09-20 18:11 猪猪🐷

55. Jump Game
摘要:55. Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. D... 阅读全文

posted @ 2018-09-20 18:07 猪猪🐷

53 Maximum Subarray
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll 阅读全文

posted @ 2018-08-10 14:36 猪猪🐷

导航