Describe a long live coding question related to market and stocks that you worked through step by step.
Implement max_profit(prices, k). Given daily stock prices, return the maximum profit achievable using at most k transactions. Each transaction consists of buying one share and later selling it, and a new transaction may begin only after the previous one is sold.
Input: prices, a list of integers, and k, a non-negative integer. Output: an integer maximum profit. Return 0 when no profitable transaction is possible.
def max_profit(prices, k):