Company: Chubb_India_26nov
Difficulty: medium
Stock Investment Profit Problem Description An investor with limited funds wants to invest in the stock market. They can buy at most one share of each company and cannot exceed their available funds. The future values of the stocks after one year have been predicted. Your task is to determine the maximum profit the investor can earn by selecting the optimal combination of stocks to buy. Complete the function selectStock which takes the following parameters: int saving : the amount available for investment. int[] currentValue : an array of the current stock values. int[] futureValue : an array of the predicted values of the stocks after one year. The function should return an integer representing the maximum profit after one year. Examples Example 1: Input: saving = 250 currentValue = [175, 133, 109, 210, 97] futureValue = [200, 125, 128, 228, 133] Output: 55 Explanation: The optimal investment strategy is to buy stocks at indices 2 and 4 (0-indexed). Total investment: 109 + 97 = 206 (w