Finding absolute difference of sums for each index in an Array
Given an array arr[] of size N, find a new array ans[] where each index i represents the absolute difference between the sum of elements to the left and right of index i in the array arr. Specifically,  ans[i] = |leftSum[i] – rightSum[i]|, where leftSum[i] is the sum of all elements to the left of index i and rightSum[i] is the sum of all elements to the right of index i....
read more
Split a String into two Substring such that the sum of unique characters is maximum
Given a string str, the task is to partition the string into two substrings such that the sum of unique characters of both substrings is the maximum possible....
read more
Minimum cost to make Array equal by increment/decrementing elements
Given an array, arr[], and the cost array cost[], the task is to find the minimum cost to make all the array elements equal by incrementing or decrementing the element at any index by 1. The cost of the increment or decrement operation for the element at index i is the cost[i]....
read more
Suffix Sum Array
Suffix Sum ArrayGiven an array arr[] of size N, the task is to compute and return its suffix sum array....
read more
Find the array element having equal count of Prime Numbers on its left and right
Given an array arr[] consisting of N positive integers, the task is to find an index from the array having count of prime numbers present on its left and right are equal....
read more
Count ways to split array into two equal sum subarrays by replacing each array element to 0 once
Given an array arr[] consisting of N integers, the task is to count the number of ways to split the array into two subarrays of equal sum after changing a single array element to 0....
read more
Difference summation with Array index matching
Given two sorted arrays A and B of size N and M respectively, the task is to find the value V, which is the summation of (A[j] – A[i]) for all pairs of i and j such that (j – i) is present in array B....
read more
Longest subarray with sum not divisible by X
Given an array arr[] and an integer X, the task is to print the longest subarray such that the sum of its elements isn’t divisible by X. If no such subarray exists, print “-1”. Note: If more than one subarray exists with the given property, print any one of them.Examples:...
read more
Count possible removals to make absolute difference between the sum of odd and even indexed elements equal to K
Given an array arr[] consisting of N integers and an integer K, the task is to find the number of times the absolute difference between the sum of elements at odd and even indices is K after removing any one element at a time from the given array....
read more
Count of ways to split an Array into three contiguous Subarrays having increasing Sum
Given an array arr[] consisting of non-negative integers, the task is to find the number of ways to split the array into three non-empty contiguous subarrays such that their respective sum of elements are in increasing order....
read more
Find the array element having equal sum of Prime Numbers on its left and right
Given an array arr[] of size N, the task is to find the index in the given array where the sum of the prime numbers present to its left is equal to the sum of the prime numbers present to its right....
read more
Minimize the Sum of Absolute Costs of an Array Optimally
Given an array arr[] of costs, your task is to minimize the sum of the absolute differences between consecutive costs by performing following operation at most once. Operation is that, we can select any index ‘i’ then make arr[i] = arr[i]/2....
read more