HouseRobbe_198

https://leetcode.com/problems/house-robber/

HouseRobbe_198_第1张图片
image.png

(图片来源https://leetcode.com/problems/house-robber/

日期 是否一次通过 comment
2019-12-01

留意下:
res[i] = max(res[i-2]+num[i], res[i-1])
有点类似斐波那契问题。


 /** 遍历 */
    public int rob(int[] nums) {
        if(nums == null || nums.length <= 0) {
            return 0;
        }

        int[] memo = new int[nums.length+1];
        memo[0] = 0;
        memo[1] = nums[0];

        for(int i=1; i

你可能感兴趣的:(HouseRobbe_198)