LeetCode198 打家劫舍的变形题目
class Solution:
def deleteAndEarn(self, nums: List[int]) -> int:
maxVal = max(nums)
total = [0] * (maxVal + 1)
for val in nums: total[val] += val
def rob(nums: List[int]) -> int:
size = len(nums)
first, second = nums[0], max(nums[0], nums[1])
for i in range(2, size):
first, second = second, max(first + nums[i], second)
return second
return rob(total)
标签:val,删除,nums,int,second,点数,total,LeetCode740
From: https://www.cnblogs.com/solvit/p/16725494.html