LeetCode 7 Dao issue stock solution to a problem link

GM stock solution of the problem is "dynamic programming" because it complies with the following features:

1, multi-stage solution model: Every day is a new stage;
2, no after-effect: define exact premise in the state, behind the stage of decision making decisions in front of the stage;

Do questions Summary:

  • 122, 123 has its own particularity, it can be combined with the characteristics of the subject of the answer;
  • No. 188 the most difficult problems, how to find out the initialization of the assignment;
  • Other issues as long as the precise definition of the state, the state transition equation is not difficult to obtain, the stock is not difficult series of questions, have confidence to do it;
  • If you are not familiar with this kind of problem, then do not start to go try to optimize space (ie compressed state) the wording, it is recommended to focus first consideration in the definition of the state and state transitions. After the write right, write the state of compression is very easy. These questions are space enough, non-essential state of compression. The state-space compression, the wording is relatively fixed, less familiar friends do not position ourselves to be one step.

The last question is monotonically stack, not so much with the entire series (count buy one get one, do together).

Question number answer
121. The best time to stock trading Violence enumeration, dynamic programming, differential thinking
122. The best time to trade stocks II Search violence, greedy algorithms, dynamic programming
III 123. the best time to buy and sell stocks Dynamic Programming
188. The best time to buy and sell stocks IV Dynamic Programming
309. The best time to buy and sell shares with the freezing of Dynamic Programming
714. The best time to buy and sell stocks with fee Dynamic Programming
901. The stock price span Visit monotonous stack usage, CSDN .
Published 442 original articles · won praise 330 · Views 1.23 million +

Guess you like

Origin blog.csdn.net/lw_power/article/details/103957975