📌📌 C++ || Sorting || Prefix Sum || Faster || Easy To Understand 🤷‍♂️🤷‍♂️
Using Sorting && Prefix Sum\n\n Time Complexity :- O(NlogN)\n\n Space Complexity :- O(1)\n\n\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n
* ***Using Sorting && Prefix Sum***\n\n* ***Time Complexity :- O(NlogN)***\n\n* ***Space Complexity :- O(1)***\n\n```\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n        \n        int n = nums.size();\n        \n        long long score = 0;\n        \n        int ans = 0;\n        \n        // sort the array in ascending order\n        \n        sort(nums.begin(), nums.end());\n        \n        // traverse over the nums from right side\n        \n        for(int i = n - 1; i >= 0; i--)\n        {\n            score += nums[i];\n            \n            if(score > 0)\n            {\n                ans++;\n            }\n        }\n        \n        return ans;\n    }\n};\n```
['Greedy', 'C', 'Sorting', 'Prefix Sum', 'C++']