easy java solution
\n\n# Approach\nsort the array and start from last index add that value in sum if sum is greater than 0 then count++ else break\n Describe your approach to solv
\n\n# Approach\nsort the array and start from last index add that value in sum if sum is greater than 0 then count++ else break\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: NlogN+N\n NlogN - > sorting Array\n N -> for loop\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 {\n    public int maxScore(int[] nums) {\n       \n        int ans=0;\n        long sum=0;\n        Arrays.sort(nums);\n        \n        for(int i=nums.length-1;i>=0;i--)\n        {\n           sum+=nums[i];\n            if(sum>0)\n            {\n                ans++;\n            }\n            else{\n                break;\n            }\n           \n        }\n        return ans;\n    }\n}\n```\n\n\uD83D\uDC46 vote
['Java']