Java || Sort & positive sum count || easy to understand || Beats 96.05%👏
IntuitionSort the array, since it'll be in ascending order, traverse from last.Approach
Sort nums
Initialize count to 0 and prefixSum to 0, and make sure prefix
# Intuition
Sort the array, since it'll be in ascending order, traverse from last.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
1. Sort nums
2. Initialize count to 0 and prefixSum to 0, and make sure prefixSum os of long, since it stores the cumulative sum of elements in nums so, to prevent integer overflow when dealing with large numbers.
3. Traverse the nums form last
4. Add the elements of nums to prefixSum.
5. Check if prefixSum is greater than 0, increase count by 1, else break.
6. At last, return count.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:O(NLogN)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int maxScore(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length;
        int count = 0;
        long prefixSum = 0;
        for(int i = n-1; i >= 0; i-- ){
            prefixSum += nums[i];
            if(prefixSum > 0){
                count +=1;
            }
            else{
                break;
            }
        }
        return count;
    }
}
```
['Java']