fork download
  1. # your code goes here
  2. class Solution(object):
  3. def maxSum(self, nums):
  4. """
  5. :type nums: List[int]
  6. :rtype: int
  7. """
  8. stack = []
  9. for num in nums:
  10. if num not in stack:
  11. stack.append(num)
  12.  
  13. _sum = 0
  14. if len(stack) == 1:
  15. _sum = stack[0]
  16.  
  17. elif max(stack) > 0:
  18. for i in range(len(stack)):
  19. if _sum < _sum+stack[i]:
  20. _sum += stack[i]
  21. else:
  22. _sum = max(stack)
  23. return _sum
  24.  
  25. return sum(stack)
Success #stdin #stdout 0.07s 14068KB
stdin
Standard input is empty
stdout
Standard output is empty