Created
April 3, 2020 17:52
-
-
Save mAlishera/ec6201ceecefe41d76edc2dd0d4a5528 to your computer and use it in GitHub Desktop.
LC 30 days challenge - DAY 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @param {Integer[]} nums | |
# @return {Integer} | |
def max_sub_array(nums) | |
max = nums[0] | |
for i in 1...nums.size do | |
nums[i] += nums[i-1] if nums[i-1] > 0 | |
max = nums[i] if nums[i] > max | |
end | |
max | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment