how about this?? *int maxinterval(int a[],int i,int j) { if(i==j) return 0; int max1 = 0,max2; max2 = maxinterval(a,i+1,j); while(i<j) { if(a[i]<a[j]) { if(j-i)>max1) max1 =j-i; } i++; } return(max1>max2?max1:max2); } * On Mon, May 16, 2011 at 11:36 AM, anuj agarwal <coolbuddy...@gmail.com>wrote:
> How about create a BST and then, for each node find the difference between > the node and its child and do this for all except leaf nodes. > If u want i will write the code for the same. > > Anuj Agarwal > > Engineering is the art of making what you want from things you can get. > > > On Mon, May 16, 2011 at 11:20 AM, anshu mishra <anshumishra6...@gmail.com > > wrote: > >> @amit ur code is wrong. just check it for this {5, 4, 1, 8, 4, 4}; >> >> --the >> You received this message because you are subscribed to the Google >> Groups "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- PIYUSH SINHA 9936757773 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.