This problem regularly features in Amazon technical interviews. Basic concept is very simple, but some more variables thrown into question, that makes it more interesting. Problem statement Given a larger integer buffer/array (say size, x), now given a window size (say, n) and a number (say, k). Windows starts from the 1st element and keeps shifting right by one element. The objective is to find the minimum k numbers present in each window. Analysis Given an array of integers, how do we find K smallest or largest elements? There are a few ways to do so. Method 1 :
Read full article from Algorithms and Me: Heaps : Sliding Window Problem
No comments:
Post a Comment