Read the problem statement here. Example: prices = [3, 2, 6, 5, 0, 3], k = 2 The key points mentioned in the problem statement are:
1. prices array contains the cost price of the stock on each day.
2. Maximum number of transactions is limited to k.
3. A stock can be…