Simple java solution
Complexity\n- Time complexity: O(n log n) \n\n- Space complexity: O(n) where n is the size of the array\n\n# Code\n\nclass Solution {\n    public int maxScore(i
# Complexity\n- Time complexity: $$O(n log n)$$ \n\n- Space complexity: $$O(n)$$ where n is the size of the array\n\n# Code\n```\nclass Solution {\n    public int maxScore(int[] num) {\n        Integer[] boxedArr = Arrays.stream(num).boxed().toArray(Integer[]::new);\n        Arrays.sort(boxedArr, Comparator.reverseOrder());\n        int[] nums = Arrays.stream(boxedArr).mapToInt(Integer::intValue).toArray();\n        int sum=0;\n        long p=0;\n        for(int i:nums)\n        {\n            p+=(long)i;\n            if(p>0)\n            {\n                sum++;\n            }\n            else\n            {\n                p=0;\n            }\n        }\n        return sum;\n    }\n}\n```
['Java']