We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 592d91a commit a72918bCopy full SHA for a72918b
Python/maximize-score-after-pair-deletions.py
@@ -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