Given an array A containg N integer you need to find total number of subarray in a given array a subarray such that there are excatly B element in array which occur at least two time code example
Example: Write a program to find the sum of all sub-arrays of a given integer array.
long int SubArraySum( int arr[] , int n )
{
long int result = 0;
// computing sum of subarray using formula
for (int i=0; i<n; i++)
result += (arr[i] * (i+1) * (n-i));
// return all subarray sum
return result ;
}