Difficulty Level : Easy
Submissions : 154
Asked In :
Marks :10
: 0 | : 1
Prefix sum at position $$$i$$$ is defined as $$$prefix[i] = arr[0]+arr[1]+....arr[i]$$$
Rearrange the given array in such a way that no of the elements which are positive in the prefix sum array is maximum
Output the maximum number of positive elements possible in the prefix array after rearranging
The first line contains $$$1 \le N \le 10^5$$$, denoting the number of elements in array $$$A$$$
The second line contains $$$N$$$ integers denoting elements of array $$$A$$$. $$$-10^9 \le A[i] \le 10^9 $$$
Output a single integer denoting the maximum number of positive elements possible in rearranged $$$A$$$.
4 -6 3 4 -10
3
4 -3 0 2 1
3
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.