If you haven’t looked at my previous post on Binary Search, then please have a look at it. Sliding Window comes in handy when attending any coding Interview in any of the big giant MNC’s(FAANG). I have encountered these patterns many times in my past coding interviews.
Let’s consider a question and see how we solve it in OLD SCHOOL way and how sliding window makes it much better. …
Binary Search is one of the most commonly asked questions in any technical interviews in top MNC’s. The basic idea is that, given an array/list with sorted elements, you have to find a certain element in it, the algorithm is based on a well know domain divide and conquer technique. It repeatedly breaks down the array in two sub-arrays which might contain the element we need and discards the other sub-array, and this goes on till the array size becomes 0 or till the element is found!