We can also build a Balanced BST for the window elements and on each shift we need to have a delete operation and add oeration. O(n logk)
Also we can add the Shashank algo where we check if the newly added element is greater than the current BST's max element. So we can discard the current BSt and start a new BST Thanks Ramindar Singh On Friday, 2 September 2011 09:04:26 UTC+5:30, Anup wrote: > > Given an unsorted Array A and any integer k where k <= size of A > > Print the maximum of each sub-array of size k of A. > > eg: A = [ 3, 5, 1, 9, 0, 4, -1, 7 ] k = 4 > Max: 9 9 9 9 7 > > -- > Anup Ghatage > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/A1g3pH1GCgUJ. 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.
