forked from Srinivas11789/AlgorithmNuggets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdel.py
More file actions
34 lines (19 loc) · 770 Bytes
/
del.py
File metadata and controls
34 lines (19 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Solution(object):
def deleteAndEarn(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
# Proper Dynamic Programming Solution - pending
# Hacky Solution
# Reference from discussions -> yangshun
def maximizeScore(points):
current = past = 0
for point in points:
past, current = current, max(point+past, current)
return current
# Array holding points of all the input, index --> points relationship
points = [0]*10001
for num in nums:
points[num] += num
return maximizeScore(points)