Given an Array 'A' of size 'N', find the number of Subarrays which have median equal to 'M'. Median of the array is defined as :
Input - [2, 1, 3, 5, 4] , N = 5 , M = 2
Output - 3
Explanation : The subarrays are [2], [2,1,3] and [2,1,3,5] hence count is 3.Note - Count of 'M' can be more than 1 in the array.
Can anyone solve it in O(n)?