标签:cto ber 实用 time stl ++ imu 初始化 and
198 House Robber
DP
0~n-1 ans=dp[n-1]
dp[i] = max(dp[i-2]+nums[i], dp[i-1]) i>=2
213 House Robber II
Since we cannot rob nums[0] and nums[n-1] at the same time, we can divide this problem into two cases:
not rob nums[0]
not rob nums[n-1]
and the answer is the maximum one.
C++ stl vector可以用 vector<int> nums1(nums.begin(), nums.end())来初始化 比较实用
LeetCode 198, 213 House Robber
标签:cto ber 实用 time stl ++ imu 初始化 and
原文地址:https://www.cnblogs.com/hankunyan/p/8874287.html