Simple greedy + sorting c++ solution
Intuition\n Describe your first thoughts on how to solve this problem. \nIn this question we have to find maximum score.It mean we have to think greedily and we
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIn this question we have to find maximum score.It mean we have to think greedily and we can even allow to change order to get maximum score.Sorting in reverse order would be perfect choice to get optimal order.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Sort the vector in Decending order.\n2. Initialise sum and ans with value of 0.\n3. Traverse through the vector and start adding element to sum.\n4. If sum is greater then 0 the increase the count of ans by 1 else break the loop\n5. Return the ans\n\n# Complexity\n- Time complexity:O(N*log(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) \n    {\n        sort(nums.rbegin(),nums.rend());\n        long long sum=0;\n        int ans=0;\n        for(int i=0;i<nums.size();i++)\n        {\n            sum+=nums[i];\n            if(sum>0) ans++;\n            else break;\n        }\n        return ans;\n    }\n};\n```
['Greedy', 'Sorting', 'C++']