-
Notifications
You must be signed in to change notification settings - Fork 29
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
Heather #9
base: master
Are you sure you want to change the base?
Heather #9
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.
Nice work, you hit all the time and space complexities and solved both problems using a dynamic programming approach. Your newman conway solution could use some simplification. Overall well done.
@@ -1,8 +1,22 @@ | |||
|
|||
# Time Complexity: ? | |||
# Space Complexity: ? | |||
# Time Complexity: O(1), where n is the number of elements in the array |
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.
Constant? Really? No this is O(n) time complexity.
series[1..num].each do |num| | ||
series_string += "#{num} " | ||
end | ||
else | ||
until counter == num | ||
counter += 1 | ||
p_next = series[series[counter - 1]] + series[counter - series[counter - 1]] | ||
series << p_next | ||
end | ||
|
||
series[1..-1].each do |num| | ||
series_string += "#{num} " | ||
end | ||
end |
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 definitely works, but could be simplified a bit. I don't think you need the if statement if already have the series array set up.
No description provided.