class Solution { public: int rob(vector<int>& nums) { int prev = 0, cur = 0; for(int i = 0; i < nums.size(); i++){ int tmp = cur; cur = max(cur, prev + nums[i]); prev = tmp; } return cur; } };