Beginner friendly||easy to understand||c++||100%beats
Intuition\nAs it is clearly mentioned in the question we have to arrange the given array in such a way that no of positive elements in the prefix of the array i
# Intuition\nAs it is clearly mentioned in the question we have to arrange the given array in such a way that no of positive elements in the prefix of the array is maximum.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nSort the array(so that all elements having highest value are at the end) and maintain the sum variable and a count variable c and keep on calculation the sum till it is greater than 0,return the count.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n- O(n*logn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n        //greater element at the end\n        sort(nums.begin(),nums.end());\n        int count = 0;\n        //to avoid integer overflow\n        long long int sum = 0;\n        for(int i = nums.size()-1;i>=0;i--){\n            sum+=nums[i];\n            if(sum > 0){\n                count++;\n            }\n            else{\n                break;\n            }\n        }\n        return count;\n    }\n};\n```
['Array', 'Greedy', 'Sorting', 'Prefix Sum', 'C++']