-
Notifications
You must be signed in to change notification settings - Fork 41
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
Leaves - Mariya #28
base: master
Are you sure you want to change the base?
Leaves - Mariya #28
Conversation
There was a problem hiding this 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| |
There was a problem hiding this comment.
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:
nums.each do |index| | |
nums.length.time do |index| |
|
||
raise NotImplementedError, "Method not implemented yet!" | ||
max = nums[0] | ||
current = nums[0] |
There was a problem hiding this comment.
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.
current = nums[0] | |
current = 0 |
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def max_sub_array(nums) |
There was a problem hiding this comment.
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. 😢
# Time complexity: O(1) | ||
# Space Complexity: O(n) | ||
|
||
def newman_helper(num, newman_hash) |
There was a problem hiding this comment.
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.
No description provided.