Skip to content

Instantly share code, notes, and snippets.

@mAlishera
Created April 3, 2020 17:52
Show Gist options
  • Save mAlishera/ec6201ceecefe41d76edc2dd0d4a5528 to your computer and use it in GitHub Desktop.
Save mAlishera/ec6201ceecefe41d76edc2dd0d4a5528 to your computer and use it in GitHub Desktop.
LC 30 days challenge - DAY 3
# @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