Skip to content

Commit

Permalink
561. Array Partition I
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Sep 26, 2018
1 parent 2a23fef commit 71a41ac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lc561. Array Partition I.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def arrayPairSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums.sort()
res = 0
for x in nums[::2]:
res += x
return res


nums = [1, 4, 3, 2]
s = Solution()
print(s.arrayPairSum(nums))

0 comments on commit 71a41ac

Please sign in to comment.