We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6df8e2f commit 96a7dc1Copy full SHA for 96a7dc1
kotlin/0122-best-time-to-buy-and-sell-stock-ii.kt
@@ -0,0 +1,9 @@
1
+class Solution {
2
+ fun maxProfit(prices: IntArray): Int {
3
+ var profit = 0
4
+ for(i in 0 until prices.size-1){
5
+ if(prices[i+1] > prices[i]) profit += (prices[i+1] - prices[i])
6
+ }
7
+ return profit
8
9
+}
0 commit comments