You must plan production for a company that manufactures multiple products. Each product has two associated costs:
Determine the minimum amount of starting cash needed to manufacture all products. Products can be produced in any order, and after completing each product, the remaining cash can be used for subsequent products.
You are given two integer arrays, worstCase and expected, where worstCase[i] and expected[i] represent the worst-case and expected costs for product i, respectively. The goal is to find the minimum starting cash required to produce all products in any order.
worstCase: An integer array representing the worst-case costs for each product.expected: An integer array representing the expected costs for each product.worstCase = [6, 5, 7], expected = [4, 2, 1]: The optimal production order is 2, 1, 0, requiring a minimum starting cash of 9 units.worstCase = [6, 7, 8], expected = [4, 4, 7]: The optimal production order is , requiring a minimum starting cash of units.(0,2,1)10worstCase = [6, 7, 8], expected = [4, 4, 7]: The optimal production order is (0,1,2), requiring a minimum starting cash of 16 units.