Skip to content

Commit

Permalink
Kotlin 53-Maximum-Subarray
Browse files Browse the repository at this point in the history
  • Loading branch information
edo-ce authored Jul 21, 2022
1 parent cc875d6 commit b6d8f3f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kotlin/53-Maximum-Subarray.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution {
fun maxSubArray(nums: IntArray): Int {
var sum = nums[0]
var currsum = 0
for (num in nums) {
currsum = maxOf(currsum + num, num)
sum = maxOf(currsum, sum)
}
return sum
}
}

0 comments on commit b6d8f3f

Please sign in to comment.