Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Merge Intervals solution and difficulty #287

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Update Merge Intervals solution and difficulty #287

wants to merge 3 commits into from

Conversation

jayvenn
Copy link

@jayvenn 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.

@jayvenn jayvenn changed the title Update Merge Intervals Update Merge Intervals solution and difficulty definition Dec 28, 2019
@jayvenn jayvenn changed the title Update Merge Intervals solution and difficulty definition Update Merge Intervals solution and difficulty Dec 28, 2019
max_current = max(max_current + nums[i], nums[i])
max_global = max(max_current, max_global)
func maxSubArray(_ nums: [Int]) -> Int {
var nums = nums
Copy link
Owner

Choose a reason for hiding this comment

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

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]] {
Copy link
Owner

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants