Simple solution with easy explanation (Python3)
Intuition\nEach prefix sum is the sum of all elements to the left (inclusive). We want to achieve the maximum number of positive integers. This means that we sh
# Intuition\nEach prefix sum is the sum of all elements to the left (inclusive). We want to achieve the maximum number of positive integers. This means that we should sort the array from largest to smallest so that we prioritise the largest values and therefore end up with the maximum possible sums at each position. \n\n# Approach\n- sort from largest to smallest\n- iteratively add each value until the sum is non-positive\n\n# Complexity\n- Time complexity:\nO(nlogn) - sorting the list is the dominant operation\n\n- Space complexity:\nO(1) - sorting the list is done in place. We need an extra int to track the sum.\n\n# Code\n```python3 []\nclass Solution:\n    def maxScore(self, nums: List[int]) -> int:\n\n        nums.sort(reverse=True) # O(nlogn)\n        \n        # O(n)\n        total = 0\n        for i, val in enumerate(nums):\n            total+= val\n            if total <= 0:\n                return i\n    \n        return len(nums)\n        \n\n\n```
['Python3']