# Tag Archives: prefix-sum

## Count of submatrix with sum X in a given Matrix

Given a matrix of size N x M and an integer X, the task is to find the number of sub-squares in the matrix with… Read More »

## Count of N-digit numbers with absolute difference of adjacent digits not exceeding K

Given two integers N and K, the task is to find the count of N-digit numbers such that the absolute difference of adjacent digits in… Read More »

## Maximum sum subarray of size range [L, R]

Given an integer array arr[] of size N and two integer L and R. The task is to find the maximum sum subarray of size… Read More »

## First subarray with negative sum from the given Array

Given an array arr[] consisting of N integers, the task is to find the start and end indices of the first subarray with a Negative… Read More »

## Count of elements having odd number of divisors in index range [L, R] for Q queries

Given an array arr[] of N positive integers and the number of queries Q, each query contains two numbers L and R. The task is… Read More »

## Minimise N such that sum of count of all factors upto N is greater than or equal to X

Given a number X, the task is to find the minimum number N such that the sum of the count of all factors from 1… Read More »

## Remove minimum characters from string to split it into three substrings under given constraints

Given a string str of lowercase alphabets, the task is to remove minimum characters from the given string so that string can be break into… Read More »

## Number of times an array can be partitioned repetitively into two subarrays with equal sum

Given an array arr[] of size N, the task is to find the number of times the array can be partitioned repetitively into two subarrays… Read More »

## Longest subarray having sum K | Set 2

Given an array arr[] of size N containing integers. The task is to find the length of the longest sub-array having sum equal to the… Read More »

## Check if sum of any subarray is Palindrome or not

Given an array arr[] of size N. the task is to check whether there exists any subarray of size atleast 2 such that its sum… Read More »

## Number of ways to obtain each numbers in range [1, b+c] by adding any two numbers in range [a, b] and [b, c]

Given three integers a, b and c. You need to select one integer from the range [a, b] and one integer from the range [b,… Read More »

## Number of ways of cutting a Matrix such that atleast one cell is filled in each part

Given an integer K and a matrix mat[][] containing 1 and 0, where 1 denotes the cell is filled and 0 denotes an empty cell.… Read More »

## Find array elements equal to sum of any subarray of at least size 2

Given an array arr[], the task is to find the elements from the array which are equal to the sum of any sub-array of size… Read More »

## Minimum Cost to make all array elements equal using given operations

Given an array arr[] of positive integers and three integers A, R, M, where The cost of adding 1 to an element of the array… Read More »

## Count of elements which are power of 2 in a given range subarray for Q queries

Given an array arr[] consisting of N positive numbers and Q queries of the form [L, R], the task is to find the number of… Read More »