Lintcode 150.买卖股票的最佳时机 II
------------------------------------------------------------
卧槽竟然连题意都没看懂,百度了才明白题目在说啥....我好方啊....o(╯□╰)o
AC代码:
class Solution { /** * @param prices: Given an integer array * @return: Maximum profit */ public int maxProfit(int[] prices) { int res=0; for(int i=1;i<prices.length;i++){ int t=prices[i]-prices[i-1]; if(t>0) res+=t; } return res; } };
题目来源: http://www.lintcode.com/zh-cn/problem/best-time-to-buy-and-sell-stock-ii/#