Skip to content

Commit a72918b

Browse files
authored
Create maximize-score-after-pair-deletions.py
1 parent 592d91a commit a72918b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# greedy
5+
class Solution(object):
6+
def maxScore(self, nums):
7+
"""
8+
:type nums: List[int]
9+
:rtype: int
10+
"""
11+
return sum(nums)-min(nums) if len(nums)%2 else sum(nums)-min(nums[i]+nums[i+1] for i in xrange(len(nums)-1))

0 commit comments

Comments
 (0)