```
class Solution {
public:
int rob(vector<int>& nums) {
if(nums.size() < 1) return 0;
nums.insert(nums.end(), 3, 0); //Insert 3 zero to solve the problem of size < 4
for(int i=nums.size()-4;i>=0;--i)
nums[i] = nums[i] + max(nums[i+2], nums[i+3]);
return max(nums[0], nums[1]);
}
};
```