
nums의 수 * 빈도 형태로 points에 저장function deleteAndEarn(nums: number[]): number {
const maxNum = Math.max(...nums)
const points = Array(maxNum + 1).fill(0)
for(const num of nums) {
points[num] += num
}
let take = 0
let skip = 0
for(let i = 0; i <= maxNum; i++) {
const curTake = skip + points[i]
const curSkip = Math.max(skip, take)
take = curTake
skip = curSkip
}
return Math.max(take, skip)
};