Shawngbk / Leecode

Questions of Leecode
0 stars 0 forks source link

122. Best Time to Buy and Sell Stock II #91

Open Shawngbk opened 7 years ago

Shawngbk commented 7 years ago

https://leetcode.com/articles/best-time-buy-and-sell-stock-ii/ public class Solution { public int maxProfit(int[] prices) { int maxprofit = 0; for(int i = 1; i < prices.length; i++) { if(prices[i] > prices[i-1]) { maxprofit += prices[i] - prices[i-1]; } } return maxprofit; } }

Shawngbk commented 7 years ago

bloomberg