## Count Subarrays with Consecutive elements differing by 1

Given an array arr[] of N integers. The task is to count the total number of subarrays of the given array such that difference between… Read More »

- Sliding Window Maximum (Maximum of all subarrays of size k) using stack in O(n) time
- Count pairs in array whose sum is divisible by K
- Greatest contiguous sub-array of size K
- Split the given array into K sub-arrays such that maximum sum of all sub arrays is minimum
- Maximum length of subarray such that sum of the subarray is even
- Range Queries to Find number of sub-arrays with a given xor
- Maximum Sum SubArray using Divide and Conquer | Set 2
- Find a subarray whose sum is divisible by size of the array
- Maximum sum of non-overlapping subarrays of length atmost K
- Maximum length of the sub-array whose first and last elements are same
- Count sub-arrays whose product is divisible by k
- Find minimum length sub-array which has given sub-sequence in it
- Maximum Subarray Sum after inverting at most two elements
- Maximize the subarray sum after multiplying all elements of any subarray with X
- Find the number of sub arrays in the permutation of first N natural numbers such that their median is M
- Sum of XOR of all sub-arrays of length K
- Maximum average of a subarray of size of atleast X and atmost Y
- Maximize the maximum subarray sum after removing atmost one element
- Sum of minimum element of all subarrays of a sorted array
- Find array such that no subarray has xor zero or Y
- Number of ways to divide an array into K equal sum sub-arrays
- Maximum length sub-array which satisfies the given conditions
- Minimum LCM and GCD possible among all possible sub-arrays
- Longest Subarray having strictly positive XOR
- Maximize the size of array by deleting exactly k sub-arrays to make array prime
- Count the number of non-increasing subarrays
- Maximum possible sub-array sum after at most X swaps
- Length of longest sub-array with maximum arithmetic mean.
- Count the number of sub-arrays such that the average of elements present in the sub-array is greater than that not present in the sub-array
- Bitwise AND of sub-array closest to K

Given an array arr[] of N integers. The task is to count the total number of subarrays of the given array such that difference between… Read More »

Given an array of N positive numbers, the task is to find a contiguous subarray (L-R) such that a[L]=a[R] and sum of a[L] + a[L+1]… Read More »

Given two arrays A[] and B[] consisting of and integers. The task is to check whether the array B[] is a subarray of the array… Read More »

Given an array of integer elements, the task is to find the length of the largest sub-array of such that all the elements of the… Read More »

Given an array A[] of integers. The task is to count the total number of strictly decreasing subarrays( with size > 1 ). Examples: Input… Read More »

Given an array of N integers and a number K, the task is to find the length of the smallest subarray in which all the… Read More »

Given an array A[] of integers. The task is to count total subarrays whose sum is prime with ( size > 1 ). Examples: Input… Read More »

Given an array arr of n elements, the task is to find the number of the sub-arrays of the given array that contain at least… Read More »

Given an array of N integers and a number K, the task is to find the number of subarrays such that all elements are greater… Read More »

Given an array with n elements. The task is to find the maximum number of contiguous array elements which have the same number of set… Read More »

Suppose you a given an array. You have to find the length of the longest subarray such that each and every element of it is… Read More »

Given an array A of n integers. The task is to find the sum of minimum of all possible (contiguous) subarray of A. Examples: Input:… Read More »

Given a number N, the task is to check if the all sub-numbers of this number have distinct digit product. Note: An N digit number… Read More »

Given an array of N numbers. The task is to maximize the number of subarrays with XOR value zero by swapping the bits of array… Read More »

Given an array of positive integers, find the smallest non-negative integer (i.e. greater than or equal to zero) that can be placed between any two… Read More »