198. House Robbers - easy

特别简单题;Linear time, constant space

public class Solution {
    public int rob(int[] nums) {
        if (nums == null || nums.length==0) return 0;
        int n = nums.length;
        if (n == 1) return nums[0];
        if (n == 2) return Math.max(nums[0], nums[1]);
        
        int two_house_before = nums[0], one_house_before = Math.max(nums[0], nums[1]), current_house = 0;
        for (int i=2; i

你可能感兴趣的:(198. House Robbers - easy)