标签:ber htm .com use col span cto nbsp tor
class Solution { public: int rob(vector<int>& nums) { int length = nums.size(); if(length <= 0) return 0; vector<int> dp(length+1); dp[0] = 0; dp[1] = nums[0]; for(int i = 1;i <= length;i++){ dp[i] = max(dp[i-2] + nums[i-1],dp[i-1]); } return dp[length]; } };
https://www.cnblogs.com/lightwindy/p/8648410.html
标签:ber htm .com use col span cto nbsp tor
原文地址:https://www.cnblogs.com/ymjyqsx/p/9652277.html