a friend of mine was asked this question in google interview.. according to me the min element in the array is the answer provided that its not zero.. as 1 element can also be a subarray. but that would solve the problem in O(n) only.. ( this is what i understood) am i missing anything..? please help..
On Sun, Jan 30, 2011 at 5:19 AM, Dan <[email protected]> wrote: > On Jan 21, 1:05 am, snehal jain <[email protected]> wrote: > > In this variation of the Maximum-Sum Subarray Problem, you are given a > > one-dimensional array A[1 : n] of positive or negative numbers, and > > you are asked to find a subarray A[i : j] such that the sum of its > > elements is (1) strictly greater than zero, and (2) minimum. In other > > words, you want to find a subarray of smallest positive sum. Give an > > O(nlog^2n) Divide and Conquer algorithm and a O(nlogn) Dynamic > > Programming Algorithm. > > There are three considerations here: > > 1) Insufficient clarity in the problem statement. > 2) Most people don't want to do others homework/school problems for > them. > 3) At very least... you need to show that you are attempting to > answer the problem yourself at least a little bit. > > -- > 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]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- 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.
