```
int rob(vector<int>& nums) {
int n = nums.size();
if(n<1) return 0;
int notin = 0; //max value if not include the current item
for(int i=1; i<n; i++){
nums[i] += notin;
notin = max(nums[i-1], notin);
}
return max(nums[n-1], notin);
}
```