Category Archives: Arrays

Count number of pair of elements whose difference is smaller than average difference

Given an array of positive integers we have to find number of pair of elements whose difference is smaller than average difference. Average difference is defined as (max(A)-min(A))/(n-1), where A is the array and max(A),min(A) is the maximum and minimum element of the array. Examples: Input : {9,3,10,2,3} Output : 2 Input : {7,9,5,3,1} Output : 0 RECOMMENDED: Characteristics or… Read More »