Skip to content

Commit ee5e766

Browse files
authoredJan 29, 2023
Merge pull request #2170 from a93a/main
Create 0122-best-time-to-buy-and-sell-stock-ii.kt
2 parents 6df8e2f + 96a7dc1 commit ee5e766

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)
Please sign in to comment.