Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

longest subarray having sum greater than half the size of subarray

I have an array of both positive and negative numbers. I want to the find the size of largest subarray whose sum is greater than or equal to the floor value of half the size of the subarray.

For e.g. in subarray 3 5 4 4 4 2 3 8 the largest subarray would be from first to the eight element and total length of subarray equal to 8. 33 >= 8/2

I wonder if there is any linear time solution to this problem

Comments