LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期

题目链接:

309. 买卖股票的最佳时机含冷冻期 - 力扣(LeetCode)

题目描述:

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第1张图片

算法图解:

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第2张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第3张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第4张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第5张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第6张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第7张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第8张图片

LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第9张图片LeetCode每日一题 | 309.买卖股票的最佳时机含冷冻期_第10张图片解题代码:
class Solution {
public:
    int maxProfit(vector& prices) {
        int n = prices.size();
        vector dp1(n+1);
        vector dp2(n+1);
        vector dp3(n+1);

        dp1[0] = 0-prices[0];

        for(int i = 1; i

 

你可能感兴趣的:(LeetCode每日一题,leetcode,算法,数据结构)