Company: Wells fargo_1sep
Difficulty: medium
Maximum Stock 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. For example, consider the following scenario: Available funds: saving = 250 Current stock values: currentValue = [175, 133, 109, 210, 97] Predicted future values: futureValue = [200, 125, 128, 228, 133] An optimal investment strategy might be to buy stocks at indices 2 and 4 (0-indexed). The current values for these stocks are 109 and 97, respectively. The total investment would be 109 + 97 = 206 , which is within the available funds (250). The predicted future values for these stocks are 128 and 133. The total future value would be 128 + 133 = 261 . The profit would then be 261 - 206 = 55 . Therefore, the