🚀✅ || Steps explained || Beginner friendly || Clean code
Intuition\n Describe your first thoughts on how to solve this problem. \nAs given in the question, we need to find no of positives after performing prefix sum.\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAs given in the question, we need to find no of positives after performing prefix sum.\nWe can also do this without using prefix array but, as we are performing prefix sum they are the chances of integer overflow so we need to declare prefix array with long datatype.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1. Sort the Array nums\n2. Reverse the Array nums\n3. Prefix sum\n4. Count no. of positives\n\n# Complexity\n- Time complexity: $$O(N*logN)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: $$O(N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n![upvotecat.jpg](https://assets.leetcode.com/users/images/e00937a5-6059-4d87-8762-f0b297f14ef4_1678593464.2677944.jpeg)\n\n\n# Code\n```\nclass Solution {\n    public int maxScore(int[] nums) {\n        \n        Arrays.sort(nums);// 1. Sort array\n\n        int n=nums.length;\n        int lastindex=n-1;\n        for(int i=0;i<n/2;i++)//2. Reverse array\n        {\n            int t= nums[i];\n            nums[i]=nums[lastindex];\n            nums[lastindex]=t;\n            lastindex--;\n        }\n        \n        long[] prefarray=new long[nums.length];// declaring with long datatype\n        prefarray[0]=nums[0];\n        \n        for(int i=1;i<nums.length;i++)//3. performing prefix sum\n        {\n            prefarray[i]=prefarray[i-1]+nums[i];\n        }\n        int count=0;\n        \n        //System.out.println(Arrays.toString(prefarray));\n        \n        for(long i:prefarray)//4. counting no. of positives\n            if(i>0)\n                count++;\n\n        return count;\n        \n    }\n}\n```\n
['Prefix Sum', 'Java']