买股票的最佳时机
股票 最佳时机
2023-09-14 08:56:53 时间
![](https://img2022.cnblogs.com/blog/1468919/202206/1468919-20220617120045283-1298877472.png)
https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/
func maxProfit(prices []int) int { n:=len(prices) vis:=make([]int,n+1) for i:=n-1;i>=0;i--{ if prices[i]>=vis[i+1]{ vis[i]=prices[i] }else{ vis[i]=vis[i+1] } } ans:=0 for i:=range prices{ if vis[i+1]-prices[i]>ans{ ans=vis[i+1]-prices[i] } } return ans }
https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/
func maxProfit(prices []int) int { ans:=0 n:=len(prices) for i:=1;i<n;i++{ if prices[i]>prices[i-1]{ ans=ans+prices[i]-prices[i-1] } } return ans }
相关文章
- Java实现 LeetCode 309 最佳买卖股票时机含冷冻期
- Java实现 LeetCode 122 买卖股票的最佳时机 II
- Java实现 LeetCode 121 买卖股票的最佳时机
- 如何使用Pythonapi函数写股票策略
- AI金融:利用LSTM预测股票每日最高价
- 【贪心】LeetCode 122. 买卖股票的最佳时机 II【中等】
- LeetCode(122):卖股票的最佳时机 II
- 每日一道 LeetCode (30): 买卖股票的最佳时机
- AI金融:利用LSTM预测股票每日最高价
- LeetCode(122):卖股票的最佳时机 II
- LeetCode - 122 买卖股票的最佳时机 II
- 买卖股票的最佳时机(C++)
- 714. 买卖股票的最佳时机含手续费-动态规划算法
- 股票配资源码系统APP股票配资系统PC版配资系统
- eodhd 财经数据 股票数据下载api python国外股票市场 json数据 tushare 股票数据
- LeetCode 121. 买卖股票的最佳时机