Skip to content

Conversation

@emilycolonq
Copy link

No description provided.

@anselrognlie anselrognlie self-requested a review July 18, 2022 23:21
Copy link

@anselrognlie anselrognlie left a 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.

🟡

Comment on lines 7 to 8
Time Complexity: ?
Space Complexity: ?

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?

Comment on lines +13 to +14
if num == 0:
raise ValueError()

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]

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

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)):

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.

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