100% Time complexity, 100% Space complexity
Approach\n Describe your approach to solving the problem. \n1. Sorting the Array:\n    - The input array nums is sorted in descending order to maximize the sum 
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Sorting the Array:\n    - The input array nums is sorted in descending order to maximize the sum of numbers. This ensures that the largest numbers are considered first, which gives the highest possible sum at each step.\n2. Summing Until Non-Positive:\n    - After sorting, the algorithm starts from the largest number and continues adding the next largest numbers from the sorted array.\n    - It stops as soon as the cumulative sum becomes non-positive (i.e., less than or equal to 0).\n3. Return the Count:\n    - The function returns the number of elements that were added to the sum before the sum became non-positive. This is effectively the "index - 1" as calculated in the loop.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n1. The sorting operation takes O(nlogn)\n2. Loop takes O(n)\n\n=> Thus, the total time complexity is O(nlogn)\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```typescript []\nfunction maxScore(nums: number[]): number {\n    nums.sort((a, b) => b - a)\n    let index = 1\n    let num = nums[0]\n    while (num > 0) {\n        num += nums[index]\n        index++\n    }\n    return index -1\n};\n\n```
['TypeScript']