Company: PayU
Difficulty: medium
Maximize Followers Problem Description N people are standing in a row, each initially having money[i] dollars. Bob has a fixed amount K . All those who have the same money as Bob become his followers. You want to perform the following task at most once to make the maximum number of people end up with the same money as Bob. Choose a subarray of people L, R ( 0 ≤ L ≤ R ≤ N-1 ) and an integer X ( -10 9 ≤ X ≤ 10 9 ). Add the amount X to each person from index L to R (i.e., money[j] = money[j] + X ). If X is negative, you are taking money from the person. Find the maximum number of followers of Bob after at most one such operation. The function to complete takes three parameters: N : Represents the number of people. K : Represents Bob's amount. money[] : Represents the initial money each person has. Examples Example 1: Input: N = 3 K = 2 Money = [6, 2, 6] Output: 2 Explanation: If you take L=0, R=2 and X=-4, you end up with money = [2, -2, 2]. Hence, 2 people become followers