Company: UIpath_5sep
Difficulty: medium
Maximize Profit with Minimum K Losses Problem Description You want to maximize the profit from a trading portfolio while taking a minimum number of losses. Given: An array pfl of n integers representing monthly profit/losses (negative values are losses). An integer k representing the minimum number of losses that must be taken. The traders can: Add any positive pfl[i] to their profit. For negative pfl[i] , either subtract it or skip it. The net profit must always be non-negative. Find the maximum total profit that can be earned after taking at least k losses. Return -1 if it is not possible to take k losses. Function Description: Complete the function getmaxProfit in the editor below with the following parameters: int[] pfl : the profit/loss predicted int k : the minimum number of losses that must be taken Returns: long : the maximum profit after taking at least k losses or -1 long getmaxProfit(vector pfl, int k) { // Complete the 'getmaxProfit' function below. // The function is expec