Beats 97%
Intuition\nWe want to maximize the positive value sums before we start decreasing the negative values\n\n# Approach\nGreedy Approach:\n\nFirst take the sum of t
# Intuition\nWe want to maximize the positive value sums before we start decreasing the negative values\n\n# Approach\nGreedy Approach:\n\nFirst take the sum of the positive values and make a list of all the negative integers.\n\nif the sum of positive values is 0 then we then answer is 0. (not possible) or if there are no negative integers, the answer is simply n.\n\nIf there are some positive and some negative:\nWe have the sum of all the positive integers, right? We know for a fact that at least the numbers we used for this sum will result in a positive prefix sum. That\'s great, we can count these numbers for our answer. \n\nAs for the negative numbers, we only want to subtract the biggest (closest to 0) negative number from the sum of all the positive numbers. This is greedy, because we want the sum to remain positive for as long as possible! So we sort the negative integers list in decreasing order, and start subtracting from the sum of positive numbers until we get to 0 or below (or if we run out of negative integers) \n\n# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```python3 []\nclass Solution:\n    def maxScore(self, nums: List[int]) -> int:\n        negative = []\n        posValue = 0\n        for num in nums:\n            if num < 0:\n                negative.append(num)\n            if num > 0:\n                posValue += num   \n        if posValue == 0:\n            return 0\n        if len(negative) == 0:\n            return len(nums)\n        ans = len(nums) - len(negative)\n        negative.sort(reverse=True)\n        for num in negative:\n            posValue += num\n            if posValue > 0:\n                ans += 1\n            else: break\n        return ans\n```
['Python3']