Swift Solution in sorted array O(nlogn)
Code\n\nclass Solution {\n    func maxScore(_ nums: [Int]) -> Int {\n        let nums = nums.sorted(by: >)\n        var subsum = 0\n        var res = 0\n\n     
# Code\n```\nclass Solution {\n    func maxScore(_ nums: [Int]) -> Int {\n        let nums = nums.sorted(by: >)\n        var subsum = 0\n        var res = 0\n\n        for num in nums {\n            subsum += num\n            if subsum > 0 {\n                res += 1\n            } else {\n                break\n            }\n        }\n\n        return res\n    }\n}\n```
['Swift']