Gets TLE because no optimizations are there but it's quick and easy to code up during an interview, so we can demonstrate the interviewer we can code something quick and fast and then move on to more sophisticated implementations of the same algorithm. Hope you like it.

```
class Solution(object):
def maxProfit(self, k, prices):
def solve(prices, k, idx, memo={}):
if idx <= 0 or not k: return 0
if (k, idx) in memo: return memo[k, idx]
nosell, sell = solve(prices, k, idx-1, memo), 0
for i in range(idx):
sell = max(sell, prices[idx] - prices[i] + solve(prices, k-1, i, memo))
memo[k, idx] = max(sell, nosell)
return memo[k, idx]
return solve(prices, k, len(prices) - 1)
```