# Tag Archives: sliding-window

## Number of subarrays with maximum values in given rangeNovember 20, 2017

Given an array of N elements and L and R, print the number of sub-arrays such that the value of the maximum array element in… Read More »

## Differences between number of increasing subarrays and decreasing subarrays in k sized windowsNovember 16, 2017

Given an array of integers and k, find the difference between the number of the strictly increasing number of subarrays (of size more than one)… Read More »

## Maximum Unique Element in every subarray of size KNovember 13, 2017

Given an array and an integer K. We need to find the maximum of every segment of length K which has no duplicates in that… Read More »

## Longest subarray not having more then K distinct elementsNovember 8, 2017

Given N elements and a number K, find the longest subarray which has not more then K distinct elements.(It can have less then K) Examples:… Read More »

## Smallest subarray with k distinct numbersNovember 5, 2017

We are given an array a consisting of n integers and an integer k. We need to find minimum range in array [l, r] (both… Read More »

## Distance of closest zero to every elementOctober 14, 2017

Given an array of n integers, for each element, print the distance to the closest zero. Array has a minimum of 1 zero in it.… Read More »

## Number of subarrays having product less than KOctober 4, 2017

Given a Array of positive numbers, calculate the number of possible subarrays having product greater than a given number K. Examples: Input : arr[] =… Read More »

## Collect maximum points in an array with k movesSeptember 6, 2017

Given an array of integer and two value k and i where k is number of moves and i is index in array. Task is… Read More »

## Longest Subarray having sum of elements atmost ‘k’September 3, 2017

Given an array of integers, our goal is to find the length of largest subarray having sum of its elements atmost ‘k’ where k>0. Examples:… Read More »

## Length of the smallest sub-string consisting of maximum distinct charactersAugust 30, 2017

Given a string of length N, find the length of the smallest sub-string consisting of maximum distinct characters. Note : Our output can have same… Read More »

## Maximum sum subarray having sum less than or equal to given sumAugust 5, 2017

Given an array of integers and a sum. We have to find sum of subarray having maximum sum less than or equal to given sum… Read More »

## Convert all substrings of length ‘k’ from base ‘b’ to decimalJuly 30, 2017

A string defining a valid number is given. Output all the base conversions of substrings of length ‘k’ from base ‘b’ to base 10. Examples:… Read More »

## Sum of product of all elements of sub-arrays of size kJuly 3, 2017

Given an array and a number k, the task is to calculate the sum of the product of all elements of subarrays of size k.… Read More »

## Count subarrays having total distinct elements same as original arrayJune 21, 2017

Given an array of n integers. Count total number of sub-array having total distinct elements same as that of total distinct elements of original array.… Read More »

## First negative integer in every window of size kJune 8, 2017

Given an array and a positive integer k, find the first negative integer for each and every window(contiguous subarray) of size k. If a window… Read More »