Company: sapient_27sep
Difficulty: medium
Maximum Segment Profit Problem Description You are reviewing how a stock performed over a stretch of consecutive months. For each month you are given one integer: a positive value is the profit earned that month, a negative value is the loss incurred that month, and zero means the month broke even. You must choose one contiguous run of months and report the total profit of that run. The run must contain at least one month, and it may span at most k months. Report the largest total you can achieve. Complete the function getMaxProfit . The function getMaxProfit has the following parameters: int pnl_count : the number of monthly profit and loss values ( n ) int pnl[] : the monthly profit and loss values int k : the largest number of months a chosen run may span Returns long : the largest total over all contiguous runs of at least 1 and at most k months. Input Format The first line contains a single integer n , the number of monthly values. Each of the next n lines contains a single intege