Crazy TeslaBAN USER
- 0of 0 votes
An array of size N is given. Array is sub divided into sub array of size K. Find maximum value of each sub array.- Crazy Tesla in India
While traversing the array keep on adding values to max heap of size K and keeping a virtual window of size K on array.
When element leaves the window then remove the leaving element from heap too and reheapify the heap. And max element of that window will be again on top in heap.
Any better approach?
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays