-
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 - Georgina #31
base: master
Are you sure you want to change the base?
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 have the newman conway sequence working, but you have some errors in the max_sub_array
method. Something to look at. If you have questions or want me to take another look let me know.
lib/max_subarray.rb
Outdated
|
||
i = 0 | ||
while i < nums.length | ||
max_ending_here = max_ending_here + a[i] |
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.
What is a?
# Time comPlexity: O(n) | ||
# Space ComPlexity: O(n) | ||
def p(n, memo) | ||
if memo[n] != nil | ||
return memo[n] | ||
end | ||
if n == 1 || n == 2 | ||
result = 1 | ||
else | ||
result = p(p(n - 1, memo), memo) + p(n - p(n - 1, memo), memo) | ||
end | ||
memo[n] = result | ||
return result | ||
end | ||
|
||
def newman_conway(n) |
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.
nice combination of recursion & dynamic programming.
No description provided.