Skip to content

Commit

Permalink
Create 0122-best-time-to-buy-and-sell-stock-ii.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
a93a committed Jan 29, 2023
1 parent 6df8e2f commit 96a7dc1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kotlin/0122-best-time-to-buy-and-sell-stock-ii.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution {
fun maxProfit(prices: IntArray): Int {
var profit = 0
for(i in 0 until prices.size-1){
if(prices[i+1] > prices[i]) profit += (prices[i+1] - prices[i])
}
return profit
}
}

0 comments on commit 96a7dc1

Please sign in to comment.