Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions improve777/MaximumSubarray.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import kotlin.math.max

class MaximumSubarray {
fun maxSubArray(nums: IntArray): Int {
var sum = nums[0]
var sub = 0
for (num in nums) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 저는 리스트에 결괏값을 담아서 구현했는데, 그럴 필요가 없겠네요. 👍

sub = if (sub < 0) num else (sub + num)
sum = max(sum, sub)
}

return sum
}
}