Given an array of integers A[1...n-1] where 'N' is the length of  array A[ ]. Construct an array B such that B[i] = min(A[i], A[i+1],  ..., A[i+K-1]), where K will be given. Array B will have N-K+1 elements.We can solve the problem using min-heapsConstruct min-heap for k elements - O(k)For every next element delete the first element and insert the new element and heapifyHence Worst Case Time - O( (n-k+1)*k ) + O(k)Space - O(k)Can we do it better?
Construct an array from an existing array
algorithms;heap