int max(int a,int b){
return a>b?a:b;
}
int rob(int* nums, int numsSize) {
if(nums==NULL||numsSize<=0)
return 0;
if(numsSize==1)
return *nums;
int pre=nums[0];
int result=max(nums[0],nums[1]);
for(int i=2;i<numsSize;++i){
int curresult=max(result,nums[i]+pre);
pre=result;
result=curresult;
}
return result;
}
return a>b?a:b;
}
int rob(int* nums, int numsSize) {
if(nums==NULL||numsSize<=0)
return 0;
if(numsSize==1)
return *nums;
int pre=nums[0];
int result=max(nums[0],nums[1]);
for(int i=2;i<numsSize;++i){
int curresult=max(result,nums[i]+pre);
pre=result;
result=curresult;
}
return result;
}