-
Notifications
You must be signed in to change notification settings - Fork 51
Spruce - Emily C #40
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?
Spruce - Emily C #40
Conversation
anselrognlie
left a comment
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.
✨ Your implementations look good, Emily! I left some comments on your implementation below.
Because of the importance of thinking about complexity for this project, I've evaluated this as a yellow due to the missing complexities for both waves. A yellow is a passing score so resubmission is not required, but you are free to resubmit with the time and space complexity filled out for a green score.
🟡
| Time Complexity: ? | ||
| Space Complexity: ? |
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.
👀 Implementation looks good, but what are the time and space complexity for this approach?
| if num == 0: | ||
| raise ValueError() |
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.
We should raise this error for any value below the valid starting point of the sequence:
if num <= 0:
raise ValueError()|
|
||
| # return ' '.join(base) | ||
|
|
||
| f = [0, 1, 1] |
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.
✨ Nice use of a buffer slot to account for the 1-based calculation.
| r = f[f[i-1]]+f[i-f[i-1]] | ||
| f.append(r) | ||
|
|
||
| return ' '.join([str(j) for j in f[1:]]) No newline at end of file |
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.
✨ Nice use of a list comprehension to convert the numeric values to strings.
Another approach would be to use the map function:
return ' '.join(map(str, f[1:]))| max_til_now = nums[0] | ||
| max_ending = 0 | ||
|
|
||
| for i in range(len(nums)): |
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.
👀 Implementation looks good, but what are the time and space complexity for this approach?
How would this compare to a "naïve" approach? Though this might not look like what we would think of as a dynamic programming approach, this article has a fairly good explanation of why it is. The main reason we look for dynamic programming approaches is to significantly improve the time complexity of an otherwise nasty algorithm.
No description provided.