Company: American_Express_SDE_Profile_11nov
Difficulty: medium
Count Contiguous Fragments with Specific Arithmetic Mean Problem Description You are given an array A of N integers and an integer S. Your task is to compute how many ways one can choose a contiguous fragment of A that has an arithmetic mean equal to S. The arithmetic mean (average) of a fragment is the sum of the elements of the fragment divided by its length. For example, the arithmetic mean of [1, 4, 4, 5] is 14/4 = 3.5. Write a function: class Solution { public int solution(int[] A, int S); } which returns the number of contiguous fragments of A whose arithmetic means are equal to S. If the result is greater than 1,000,000,000, your function should return 1,000,000,000. Examples Example 1: Input: A = [2, 1, 3], S = 2 Output: 3 Explanation: The arithmetic means of fragments [2], [1, 3] and [2, 1, 3] are equal to 2. Example 2: Input: A = [0, 4, 3, -1], S = 2 Output: 2 Explanation: Fragments [0, 4] and [4, 3, -1] have an arithmetic mean equal to 2. Example 3: Input: A = [2, 1, 4], S =