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....
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....
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]....
Suffix Sum ArrayGiven an array arr[] of size N, the task is to compute and return its suffix sum array....
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....
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....
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....
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:...
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....
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....
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....
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....