Leetcode : Best Time To Buy And Sell Stock IV

  1. You can make at most ‘k’ transactions.
  2. You cannot engage in multiple transactions. (i.e. Harshad Mehta, if you have bought a stock, before buying any new stock you have to sell this pre-possessed stock)

Let’s recursively think of my choices under the conditions,

At any point I can either buy a stock or I can sell an already bought stock. I cannot buy any new stock before I sell my already possessed stock.

Driver Function
recursive function
driver function
memoized recursive solution
bottom up dp

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Gururani

Abhishek Gururani

I write articles on Android Development, and problem solving.