博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Best Time to Buy and Sell Stock II
阅读量:7022 次
发布时间:2019-06-28

本文共 515 字,大约阅读时间需要 1 分钟。

Say you have an array for which the ith element is the price of a given stock on day i.

Design an algorithm to find the maximum profit. You may complete at most two transactions.

Note:

You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).

 

Code:

class Solution {public:    int maxProfit(vector
&prices) { int cur=0; int maxProf=0; int tmpProf=0; for(int i=1;i

 

 

转载于:https://www.cnblogs.com/winscoder/p/3398374.html

你可能感兴趣的文章
17秋 软件工程 第六次作业 Beta冲刺
查看>>
html5--6-23 CSS3中的文字与字体
查看>>
使用腾讯云无服务器云函数(SCF)分析天气数据
查看>>
Android系统编译错误Note: Some input files use or override a deprecated API. 解决办法【转】...
查看>>
Redis进阶实践之四Redis的基本数据类型
查看>>
006-Spring Boot自动配置-Condition、Conditional、Spring提供的Conditional自动配置
查看>>
URAL Palindromic Contest
查看>>
Spring Cloud启动应用时指定IP或忽略某张网卡配置
查看>>
RequireJS 和 Sea.js
查看>>
你做了哪些事,导致老板下调了对你的评价?
查看>>
基于JWT的Token开发案例
查看>>
linux下最简单的端口转发工具
查看>>
聊聊并发(七)——Java中的阻塞队列
查看>>
命题和判断有什么区别和联系
查看>>
[INet] I/O模型:同步阻塞,同步非阻塞,异步非阻塞
查看>>
微信即将支持App直接打开小程序
查看>>
织云Lite发布:详解包管理核心能力
查看>>
TensorFlow 图像预处理(一) 图像编解码,图像尺寸调整
查看>>
029_mac下nginx管理
查看>>
hadoop04---shell
查看>>