We can modify it by keeping track of minimum element as well and find diff of that with all elements(say max_diff) and at each iteration we can find the minimum of max_diff and min_diff
On Aug 17, 9:34 am, Ankuj Gupta <[email protected]> wrote: > I assumed that we can find min diff when we subtract elements of array > from the max element > > On Aug 16, 11:18 pm, Anurag Narain <[email protected]> wrote: > > > > > > > > > @ankuj: > > > i think the solution is not correct.. > > > could u please explain ur algo for > > > 5,13,7,0,10,20,1,15,4,18 > > > acc to ur algo answer is 2 but it should be 1(1-0) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
