Skip to main content
股市买卖问题

股市买卖问题

故事买卖类的问题主要使用动态规划进行解决,只是复杂程度不同罢了。

递归方程的建立考虑以下问题:

  • 目的:能够获得的最大利润

  • 联系:一共有n天需要记录,每天有两种状态,当天有股票或没股票

    • 今天没有股票:昨天也没买今日未操作,或者卖掉股票获得钱
    • 今天有股票:昨天就已经买入股票今日未操作,或者今日买入股票
  • 优化:是否需要记录每一天,还是只与上一天的结果有关。


Yujie LiuAbout 10 minComputer ScienceAlgorithmsLeetcodeDynamic Programming
Dynamic Programming 动态规划

Dynamic Programming 动态规划

This blog records the solutions I made for the Dynamic Programming questions from Leetcode.

Fibonacci related problems

Firstly, find out the transformation function for the problem.

Then, from the starting point to calculate the results by iterating the array.


Yujie LiuAbout 11 minComputer ScienceAlgorithmsLeetcodeDynamic Programming