Construct sum-array with sum of elements in given range

You are given an array of n-elements and an odd-integer m. You have to construct a new sum_array from given array such that sum_array[i] =… Read More »

Find mean of subarray means in a given array

You are given an array of n-elements you have to find the mean of the array as mean of all consecutive m-elements of array for… Read More »

Number of subarrays with maximum values in given range

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 windows

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 K

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 than K distinct elements

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

Smallest subarray with k distinct numbers

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

Distance of closest zero to every element

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 K

Given an Array of positive numbers, calculate the number of possible contigous subarrays having product lesser than a given number K. Examples : Input :… Read More »

Collect maximum points in an array with k moves

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’

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 characters

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 sum

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 decimal

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 k

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 »