public static int rob(int[] nums) {
    int length = nums.length;
    if (length <= 0) return 0;
    int[] robs = new int[length];
    int[] norobs = new int[length];
    robs[0] = nums[0];
    norobs[0] = 0;
    for (int i = 1; i < length; i++) {
      norobs[i] = robs[i - 1];
      robs[i] = norobs[i - 1] + nums[i];
      if (robs[i] < robs[i - 1]) robs[i] = robs[i - 1]; 
    }
    return robs[length - 1] > norobs[length - 1] ? robs[length - 1] : norobs[length - 1];
  }