-
Notifications
You must be signed in to change notification settings - Fork 43
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
base: master
Are you sure you want to change the base?
Ports - Kasey #28
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.
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? |
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.
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 |
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.
I reckon you can get to constant space though - any ideas on how you'd do it?
No description provided.