Company: Amazon_26aug
Difficulty: medium
Subarray Median Count Problem Description Engineers at a cloud hosting provider are load-testing a fleet of servers. As part of the simulation, n requests are fired at the fleet, and the k th request has a size of requests[k] units. Given the array requests and an integer mid , count how many subarrays of requests have a median equal to mid . Note: The median of an array is the value sitting in the middle once the array is sorted. When the array has an even number of elements there are two middle values, and in that case the median is taken to be the smaller of the two. A subarray is any contiguous run of elements from the array. Complete the function getSubarrayMedian in the editor below. getSubarrayMedian has the following parameters: int mid : the target median int requests[] : the sizes of the requests Returns long int : the number of subarrays of requests with a median of mid Examples Example 1: Input: n = 3, requests = [1, 2, 3], mid = 2 Every possible subarray is: [1], [2], [3],