Kadanes algo Simple
Intuition: KADANE\u2019S Algorithm \nAs the question state we can arrange in any order. So Sort the given array and find all the Prefixsum which is greater than
Intuition: KADANE\u2019S Algorithm \nAs the question state we can arrange in any order. So Sort the given array and find all the Prefixsum which is greater than 0 and then increase count and when ever we encounter PrefixSum<0 we have to make it 0.\nAs we can see in the explanation also 0 is not counted in the examples. So we have to discard and take all the Prefixsum >0 and based on this our count will be increased.\nThe time complexity is O(nlogn) bcoz of sorting. Overall time complexity due to our for loop is O(N).\nThank You.\n\nPlease Upvote if you like the approach.\n\n```\nclass Solution {\n    public int maxScore(int[] nums) {\n        \n       long sum=0;\n        int count=0;\n        Arrays.sort(nums);\n        for(int i=nums.length-1;i>=0;i--){\n            sum+=nums[i];\n            \n            if(sum>0){\n                count++;\n            }else{\n                sum=0;\n            }\n        }\n        return count;\n    }\n}\n```
['Array', 'Sorting', 'Java']