Skip to content

Conversation

@tt-ht
Copy link

@tt-ht tt-ht commented Jun 9, 2022

No description provided.

Copy link

@kyra-patton kyra-patton left a comment

Choose a reason for hiding this comment

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

✨ Nice work Tanya! I left one comment on the space complexity of max_sub_array. Let me know what questions you have.

🟢

Returns 0 if nums is None or an empty list.
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(n)

Choose a reason for hiding this comment

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

✨ Your implementation works, however space complexity would be O(1). Whatever the length of the input, n, you are only ever taking up a constant amount of additional space through the two variables max_so_far and max_ending_here.

Time Complexity: ?
Space Complexity: ?
Time Complexity: O(n)
Space Complexity: O(n)

Choose a reason for hiding this comment

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

Comment on lines +19 to +20
if max_ending_here < 0:
max_ending_here = 0

Choose a reason for hiding this comment

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

Good observation 🌸

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