-
Notifications
You must be signed in to change notification settings - Fork 51
Algorithms-Python #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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,16 @@ def newman_conway(num): | |
| Time Complexity: ? | ||
| Space Complexity: ? | ||
|
Comment on lines
7
to
8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Implementation looks mostly good again here, but what about time and space complexity? |
||
| """ | ||
| pass | ||
| if num < 1: | ||
| raise ValueError("Must be a positive number") | ||
| if num == 1: | ||
| return "1" | ||
|
|
||
| current_list = [0, 1, 1] | ||
|
|
||
| count = 3 | ||
| while count <= num: | ||
| current_list.append(current_list[current_list[count - 1]] + current_list[count - current_list[count - 1]]) | ||
| count += 1 | ||
|
|
||
| return [str(item) for item in current_list] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 To pass the tests, you want to return the newman conway numbers as a string (ex. "0 1 1") instead of a list of strings |
||
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.
🤔 Implementations looks great, but what about time and space complexity?