# Tag Archives: prefix-sum

## Maximum array sum with prefix and suffix multiplications with -1 allowedNovember 21, 2017

Given N elements (both positive and negative). Find the maximum sum, provided that the first operation is to take some prefix of the sequence and… Read More »

## Longest subsequence of the form 0*1*0* in a binary stringNovember 7, 2017

Given a binary string, find the longest subsequence of the form (0)*(1)*(0)* in it. Basically we need to divide the string into 3 non overlapping… Read More »

## Count Primes in RangesOctober 27, 2017

Given a range [L, R], we need to find the count of total numbers of prime numbers in the the range [L, R] where 0

## Mean of range in arrayOctober 13, 2017

Given an array of n integers. You are given q queries. Write a program to print floor value of mean in range l to r… Read More »

## Print modified array after executing the commands of addition and subtractionOctober 11, 2017

Given an array of size ‘n’ and a given set of commands of size ‘m’. Every command consist of four integers q, l, r, k.… Read More »

## Count of substrings of a binary string containing K onesOctober 8, 2017

Given a binary string of length N and an integer K, we need to find out how many substrings of this string are exist which… Read More »

## Find an element in array such that sum of left array is equal to sum of right arraySeptember 7, 2017

Given, an array of size n. Find an element which divides the array in two sub-arrays with equal sum. Examples: Input : 1 4 2… Read More »

## Minimum absolute difference of XOR values of two subarraysSeptember 6, 2017

Given an array containing n numbers. The problem is to split the array into two subarrays such that the absolute difference of the xor values… Read More »

## Count subarrays with equal number of occurrences of two given elementsAugust 27, 2017

Given an array and two integers say, x and y, find the number of subarrays in which the number of occurrences of x is equal… Read More »

## Print modified array after multiple array range increment operationsJuly 30, 2017

Given an array containing n integers and a value d. m queries are given. Each query has two values start and end. For each query,… Read More »

## Find the Sub-array with sum closest to 0July 3, 2017

Given an array of both positive and negative numbers, the task is to find out the subarray whose sum is closest to 0. There can… Read More »

## Count the number of ways to divide an array into three contiguous parts having equal sumMay 18, 2017

Given a array of n numbers. Our task is to find out the number of ways to divide the array into three contiguous parts such… Read More »

## Maximum sum two non-overlapping subarrays of given sizeMay 14, 2017

Given an array, we need to find two subarrays with a specific length K such that sum of these subarrays is maximum among all possible… Read More »

## Prefix Sum Array – Implementation and Applications in Competitive ProgrammingMay 10, 2017

Introduction and Implementation : Given an array arr[] of size n, its prefix sum array is another array prefixSum[] of same size such that the… Read More »

## Minimum cost for acquiring all coins with k extra coins allowed with every coinApril 24, 2017

You are given a list of N coins of different denominations. you can pay an amount equivalent to any 1 coin and can acquire that… Read More »