Skip to content

Commit 96a7dc1

Browse files
committed
Create 0122-best-time-to-buy-and-sell-stock-ii.kt
1 parent 6df8e2f commit 96a7dc1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)