class Solution {
public:
/**
* @param prices: Given an integer array
* @return: Maximum profit
*/
int maxProfit(vector<int> &price) {

int re = 0;
if(price.size()<2)
return re;
int lowest = price[0];
for(int i=1;i<price.size();i++)
{
int cur = price[i];
re = max(re,cur-lowest);
lowest = min(lowest,cur);
}
return re;
}
};

最新文章

  1. C++ 系列:设计模式研究
  2. [再寄小读者之数学篇](2014-11-26 广义 Schur 分解定理)
  3. hdu-4753-Fishhead’s Little Game-记忆化搜索
  4. BZOJ 2693 jzptab
  5. 学习sql基础注入的方法
  6. Activiti-06-.事件
  7. Jmeter+Ant+Jenkins接口自动化测试(一)_环境部署
  8. Linux系统 Cetos 7 中重置root密码
  9. Java_面向对象
  10. Python内置函数(21)——filter
  11. 20172328 2018-2019《Java软件结构与数据结构》第五周学习总结
  12. Effective Java 第三版——48. 谨慎使用流并行
  13. (转)Springboot邮件服务
  14. python 安装 Scrapy 模块
  15. servlet实现文件上传,预览,下载和删除
  16. 搭建iSCSI共享IPSAN
  17. get与post请求简单理解
  18. softmax回归(理论部分解释)
  19. Notes about Vue Style Guide
  20. virtio使用

热门文章

  1. Python web前端 09 jQuery
  2. 【记录】SQL注入过滤源码分享
  3. python学习13-类的约束 异常处理 日志
  4. CSS3--底部菜单上拉效果
  5. Maven---pom.xml 详解(转)
  6. 【OpenCV-python】CV2和PIL按box信息实现图像裁剪
  7. (转)网站速度优化技巧:Nginx设置js、css过期时间
  8. ABP文档笔记 - 模块系统 及 配置中心
  9. C#下查找并杀死子进程(进程树)
  10. Hashtable和HashMap的区别,Properties类的简单使用