Hello, Algorithm--> 1. Find out start and end index of contiguous subarray which has max sum O(n) 2.Once u have start and end index calculate avg if it satisfies the condition then done O(n) 2.1 other wise run a loop through start to end index and remove trailing elements by increasing start 2.2 simultaneously check avg..this will lead to proper subarray. 3. In similar fashion start reducing end valuse keeping start constant.....do it sub steps of 2...
compare result of 2 and 3 and choose d best one... give me some time to write code.... On Wed, Nov 21, 2012 at 12:29 AM, Koup <[email protected]> wrote: > To be correct I need the longest subarray that has an average greater than > k but my main problem here is to find the longest one. Thank you ! > > -- > > > -- Regards, Sachin Chitale Application Engineer SCJP, SCWCD Contact# : +91 8086284349, 9892159511 Oracle Corporation --
