# Tag Archives: prefix-sum

Given an array arr[]. Find the maximum number of indices having 0 as prefix sums possible by replacing the 0s in the array with any… Read More
Given two arrays A[] and B[] both of size N, the task is to count the number of non-decreasing arrays C[] of size N such… Read More
Given two arrays arr1[] and arr2[] of size N and M (M < N) add all elements of arr2[] in all possible subarrays of arr1[]… Read More
Given two arrays X[] and Y[] of length N each. You can shift from X[] to Y[] at most once. The task is to output… Read More
Given a binary string S consisting of ‘0‘ and ‘1‘ only, the task is to find the maximum possible number of “10” subsequences by replacing… Read More
Given an array arr[] consisting of N  integers and an array Q[][3] consisting of M queries of the form [L, R, U], the task for… Read More
Given a binary string S of length N, the task is to find the number of ways to select three indices such that if they… Read More
Given an array arr[] of size, N, the task is to maximize the score to reduce the array to a single element by replacing any… Read More
Given a string S and an array roll[] where roll[i] represents incrementing first roll[i] characters in the string, the task is to increment all the… Read More
Given a matrix of dimension N*N whose all cells are initially 0. You are given Q queries, each of type {a, b, c, d} where… Read More
Given an array arr[] consisting of N distinct integers and an array Q[][2] consisting of M queries of the form [L, R], the task for… Read More
Given an array ranges[] of size N (1 ≤ N ≤ 105), where ranges[i] = {starti, endi} represents the range between starti to endi (both… Read More
Given a 2D array arr[][] where each array element denotes a point in the X axis and the number of elements on that point. A… Read More
Given an array nums[] of size N, the task is to find the maximum difference between the sum of even and odd indexed elements of… Read More
Given an array A[] of size N (0 ≤ A[i] ≤ 109). The following operations can be performed on the array. Choose a random integer… Read More