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

Heather #9

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

Heather #9

wants to merge 3 commits into from

Conversation

piffer59
Copy link

@piffer59 piffer59 commented Oct 6, 2019

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.

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

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.

Comment on lines +17 to +31
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

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.

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