public int rob(int[] nums) {

```
int tmp1=0,tmp2=0,tmp3=0;
int max=0;
for(int i=0; i<nums.length; i++){
int tmp = Math.max(tmp1+nums[i], tmp2+nums[i]);
tmp1 = tmp2;
tmp2 = tmp3;
tmp3 = tmp;
max = Math.max(max, tmp);
}
return max;
}
```