121. Best Time to Buy and Sell Stock
来源:互联网 发布:微创软件怎么样 编辑:程序博客网 时间:2024/06/07 16:59
public int maxProfit(int[] prices) { if(prices.length<2){ return 0; } int re=0; int low=prices[0]; for(int i=1; i<prices.length; i++){ if(prices[i]<low){ low=prices[i]; }else{ re=Math.max(re, prices[i]-low); } } return re; }
对这类问题还不太熟悉
0 0
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time To Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock
- Run queue of FreeBsd
- poj1465Multiple(经典BFS+余数判重)
- 引用类型——Java数组
- Android Studio 2.1 和 Unity3D 5.3.4 交互
- 28. Implement strStr()
- 121. Best Time to Buy and Sell Stock
- 自定义非等高cell02-xib
- Unity3D 摄像机(Camera)属性详解
- onvif的soap消息之getcapabilities
- iOS动画浅汇
- Java字符串编码和转换操作
- jQuery事件绑定和委托实例
- 给你的右键添加 to dos
- 树——二叉树的后序遍历(非递归)