class Solution {
public:
int massage(vector<int>& nums) {
int n = nums.size();
if(!n)
{
return 0;
}
int dp0 = 0,dp1 = nums[0];
for(int i = 1;i < n;i++)
{
int tdp0 = max(dp0,dp1);
int tdp1 = dp0 + nums[i];
dp0 = tdp0;
dp1 = tdp1;
}
return max(dp0,dp1);
}
};
leetcode每日一题第119天
最新推荐文章于 2024-11-13 11:37:20 发布