Update Merge Intervals solution and difficulty#287
Open
jayvenn wants to merge 3 commits intosoapyigu:masterfrom
jayvenn:master
Open
Update Merge Intervals solution and difficulty#287jayvenn wants to merge 3 commits intosoapyigu:masterfrom jayvenn:master
jayvenn wants to merge 3 commits intosoapyigu:masterfrom
jayvenn:master
Conversation
jayvenn
commented
Dec 28, 2019
- Update deprecated solution with new method signature and removal of Interval class definition.
- Mirror Merge Intervals question difficulty definition with LeetCode link.
…and simplify value reference in for-loop
soapyigu
requested changes
Jan 21, 2020
| max_current = max(max_current + nums[i], nums[i]) | ||
| max_global = max(max_current, max_global) | ||
| func maxSubArray(_ nums: [Int]) -> Int { | ||
| var nums = nums |
Owner
There was a problem hiding this comment.
Why do you need to use a local nums
| let intervals = intervals.sorted { | ||
| if $0.start != $1.start { | ||
| return $0.start < $1.start | ||
| func merge(_ intervals: [[Int]]) -> [[Int]] { |
Owner
There was a problem hiding this comment.
Your solution works but it is almost the same logic as the original one. Since it does not help improve the runtime complexity or simplify the code, I will not merge it.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.