igor way is the optimized way using prefix sum just a small correction with in life period of (l,r) you have to do v[l]++, v[r+1]--(v is initialized to zero ) take a prefix sum of v and return the max value containing index
On Thursday, February 21, 2013 3:10:17 PM UTC+5:30, NITHIN HOTKER wrote: > > Given life time of different elephants find *period when maximum number > of elephants lived.* > Eg [5, 10], [6, 15], [2, 7] etc. year in which max no elephants exists. > > When this is put on paper the answer is [6,7] . > > Is it* [Max(start interval),Min(end interval)] * such that start < end > interval ?? I've checked this for 2-3 cases and it works . > > Given another interval , find set of intervals in which given point lies . > This could be done using augumented data-structure using Tree . > > Let's create a balanced BST using the asc order {2,5,6,7,10,15} > > What after this ??? > > > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.