Skip to content

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.


# 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
if num < 2
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