class Solution {
public:
int f[110],g[110];//分别表示第i个房屋偷,不偷的最大价值
int rob(vector<int>& nums) {
int n=nums.size();
for(int i=1;i<=n;i++)
{
g[i]=max(f[i-1],g[i-1]);
f[i]=g[i-1]+nums[i-1];
}
return max(f[n],g[n]);
}
};
标签:nums,int,LeetCode198,Solution,110,打家劫舍
From: https://www.cnblogs.com/tangxibomb/p/17382988.html