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

Ports - Kasey #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Ports - Kasey #28

wants to merge 1 commit into from

Conversation

kaseea
Copy link

@kaseea kaseea commented Apr 22, 2019

No description provided.

Copy link

@ace-n ace-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing, but we can probably improve (space) complexity a bit. (See comments. 🙂)

Any ideas on how you'd do that?

@@ -5,8 +5,18 @@
# ....
# e.g. 6th fibonacci number is 8

# Time complexity: ?
# Space complexity: ?
# Time complexity: 0(n), where the program only loops through it n times (well, n - 2 times because the first few things are hardcoded cases), was wondering if it was better to do it with recursion? but that would run it with recursion instead of saving everything in an array and indexing it, but I think that would run more times?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of get what n is here, but loops through it n times is a bit of a tautology.

Can you explain it more clearly perhaps? e.g. O(n), where n = the number of digits in the input number or O(n), where n = the input number itself.

# Time complexity: ?
# Space complexity: ?
# Time complexity: 0(n), where the program only loops through it n times (well, n - 2 times because the first few things are hardcoded cases), was wondering if it was better to do it with recursion? but that would run it with recursion instead of saving everything in an array and indexing it, but I think that would run more times?
# Space complexity: constant, although you have to initialize space for an array
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️Are you sure? That array looks like it's linear to me.

I reckon you can get to constant space though - any ideas on how you'd do it?

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