Skip to content

Conversation

@SoCodeDo
Copy link

@SoCodeDo SoCodeDo commented Nov 9, 2020

Chris, I wasn't sure on how to do start the final one, but wanted to get this in. I will try to re-attempt this week. Thanks!

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Thanks for getting in what you did. Not bad, you had the methods right, just look at my feedback regarding the time/space complexity.

Comment on lines +3 to 5
# Time complexity: O(n)
# Space complexity: O(n)
def factorial(n)

Choose a reason for hiding this comment

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

👍

Comment on lines +15 to 17
# Time complexity: O(n)
# Space complexity: O(n)
def reverse(s)

Choose a reason for hiding this comment

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

👍 However the space & time complexity are O(n^2) because the slice you do has space/time complexity of O(n)

Comment on lines +25 to 27
# # Time complexity: O(1)
# # Space complexity: O(1)
def reverse_inplace(s)

Choose a reason for hiding this comment

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

⚠️ How could you reverse an entire string in O(1) time?

Also you're using the exact method I told you not to use.

Comment on lines +35 to -24
# # Time complexity: O(n)
# # Space complexity: O(n)
def bunny(n)
raise NotImplementedError, "Method not implemented"

Choose a reason for hiding this comment

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

👍

Comment on lines +45 to 47
# # Time complexity: O(n^2) * not sure about this one
# # Space complexity: O(n^2) * same here?
def nested(s)

Choose a reason for hiding this comment

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

👍 Correct!

Comment on lines +58 to 60
# # Time complexity: O(n)
# # Space complexity: O(n^2)
def search(array, value)

Choose a reason for hiding this comment

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

This works, but once again the time complexity is O(n^2)

Comment on lines +71 to 73
# # Time complexity: O(n)
# # Space complexity: O(n)
def is_palindrome(s)

Choose a reason for hiding this comment

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

This works, but once again the time complexity is O(n^2)

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