Skip to content

Conversation

@M-Burr
Copy link

@M-Burr M-Burr commented Mar 31, 2020

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Well you got the newman_conway method, but it looks like you weren't able to finish the subsequence problem. I pointed out a few things there, let me know if you have further questions.

max = nums[0]
current = nums[0]

nums.each do |index|

Choose a reason for hiding this comment

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

index here won't be an index into the array, it will be a value.

Maybe you meant:

Suggested change
nums.each do |index|
nums.length.time do |index|


raise NotImplementedError, "Method not implemented yet!"
max = nums[0]
current = nums[0]

Choose a reason for hiding this comment

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

Otherwise you will add nums[0] twice.

Suggested change
current = nums[0]
current = 0

Comment on lines +2 to 4
# Time Complexity: O(n)
# Space Complexity: O(1)
def max_sub_array(nums)

Choose a reason for hiding this comment

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

I think you're on the right track, but not quite there yet. 😢

Comment on lines +3 to +6
# Time complexity: O(1)
# Space Complexity: O(n)

def newman_helper(num, newman_hash)

Choose a reason for hiding this comment

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

This works, although you could use an array just as easily as a hash here.

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.

2 participants