In sliding window technique, we maintain a window that satisfies the problem constraints. The window is unstable if it violates the problem constraints and it tries to stabilize itself by increasing or decreasing it’s size.

Below are some of commonly asked interview questions that uses sliding window technique –

### 1. Find the longest substring of given string containing k distinct characters

*Given a string and a positive number k, find the longest substring of given string containing k distinct characters. If k is more than number of distinct characters in the string, return the whole string.*

### 2. Find all substrings of a string that are permutation of a given string

*Find all substrings of a string that contains all characters of another string. In other words, find all substrings of first string that are anagrams of second string.*

### 3. Longest substring of given string containing distinct characters

*Given a string, find the longest substring of given string containing distinct characters.*

### 4. Find index of 0 to be replaced to get maximum length sequence of continuous ones

*Given a binary array, find the index of 0 to be replaced with 1 to get maximum length sequence of continuous ones.*

### 5. Find the maximum sequence of continuous 1’s that can be formed by replacing at-most k zeroes by ones

*Given an Boolean array, find the maximum sequence of continuous 1’s that can be formed by replacing at-most k zeroes by ones.*

### 6. Find minimum sum subarray of given size k

*Given an array of integers, find minimum sum sub-array of given size k.*

### 7. Find subarray having given sum in given array of integers

*Given an array of integers, find a sub-array having given sum in it.*

### 8. Find the length of smallest subarray whose sum of elements is greater than the given number

*Given an array of integers, find the length of smallest subarray whose sum of elements is greater than the given positive number.*

**Thank you for being with us. 🙂**

Like us? Please spread the word and help us grow. Happy coding 🙂

## Leave a Reply