Lintcode:买卖股票的最佳时机
2016-04-07 15:47
330 查看
Lintcode:买卖股票的最佳时机
class Solution: """ @param prices: Given an integer array @return: Maximum profit """ def maxProfit(self, prices): # write your code here if(len(prices)==0): return 0 lowest_price = prices[0] ans = 0 for i in range(len(prices)): ans = max(ans, prices[i]-lowest_price) lowest_price = min(prices[i], lowest_price) return ans
相关文章推荐
- cf#312-E-A Simple Task- 线段树+暴力(计数排序)
- 升级JDK版本后,SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializ
- Android手机在开发调试时logcat不显示输出信息的解决办法
- iOS项目中安装和使用 Cocoapods
- 网络原理,以及对VMware Workstation虚拟网络VMnet0、VMnet1、VMnet8的图解
- Windows下react-native安装步骤以及安装时候遇到各类已填平的坑
- NSTimer扩展block版(用block写定时器)
- 7.2 LOCAL_STATE:virtual模块核心结构体
- hosts文件地址
- 面试题49 把字符串转换成整数
- Beat---hdu2614
- DBText除了左右左对齐且上下Base对齐的其对齐点为Position外,其余的都是AlignmentPoint
- 2016年上半年系统集成中项4月6日作业
- zabbix中文乱码解决方法
- TCP server 为什么一个端口可以建立多个连接?(网络讨论)
- uart stdio的移植3
- C++设计模式<二>:面向对象设计原则
- 保留两位小数
- MySQL修改root密码的多种方法
- BZOJ 2728: [HNOI2012]与非