解决思路
public int rob(int[] nums){
if (nums.length == 0)
return 0;
if (nums.length == 1)
return nums[0];
return Math.max(myRob(Arrays.copyOfRange(nums,0,nums.length-1)),myRob(Arrays.copyOfRange(nums,1,nums.length)));
}
private int myRob(int[] num){
int preMax = 0;
int currMax = 0;
for (int i:num){
int temp = currMax;
currMax = Math.max(preMax + i,currMax);
preMax = temp;
}
return currMax;
}