Yeah i have worked on modifying that algorithm for some hours.But I have 
problem when the sum is negative but the next element is a positive integer 
that will make my sum correct. In that case the algorithm makes my sum zero 
cause it was negative. Any help on that?

On Tuesday, November 20, 2012 7:17:32 PM UTC+2, Sachin Chitale wrote:
>
> Use Kadane's algorithm to solve this with time complexity O(n) and Space 
> O(1)
> http://www.algorithmist.com/index.php/Kadane's_Algorithm
>
> Need to modify a bit.
>
>
> -- 
> Regards,
> Sachin Chitale
> Application Engineer SCJP, SCWCD
> Contact# : +91 8086284349, 9892159511
> Oracle Corporation
>
> On Tue, Nov 20, 2012 at 10:43 PM, Koup <[email protected] 
> <javascript:>>wrote:
>
>> Consider an array of N integers. Find the longest contiguous subarray 
>> so that the average of its elements is greater than a given number k 
>>
>> I know the general brute force solution in O(N^2). Is there any 
>> efficient solution using extra space?
>>
>> -- 
>>  
>>  
>>
>
>
>
>  

-- 


Reply via email to