Company: Maq_27oct
Difficulty: medium
Another Subarray Problem Problem Description Mr. Hola, being a very lazy teacher, has copied a very popular problem from the internet. The problem was the maximum subarray problem. He has made a slight modification to the problem. He has introduced a negative integer M. For each index i , he asks the students to find the maximum subarray sum if he replaced the element at index i with M . Input Format In the first line, you are given two integers N, M . Next line contains N space-separated integers denoting the elements of the array. Output Format Find the maximum subarray sum for each index i when element at i -th index is replaced with M . Constraints 1 <= N <= 10^5 1 <= A[i] <= 10^9 -10^9 <= M <= 0 Examples Example 1: Input: 4 -3 1 2 3 4 Output: 9 7 4 6 Explanation: Let the original array be A = [1, 2, 3, 4] and M = -3 . After replacing the first element (at index 0) with M : The array becomes [-3, 2, 3, 4] . The maximum subarray sum is 2 + 3 + 4 = 9 . After replaci