-
Notifications
You must be signed in to change notification settings - Fork 53
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
Water - Sophia #43
base: master
Are you sure you want to change the base?
Water - Sophia #43
Conversation
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.
Thanks for getting in what you did. Not bad, you had the methods right, just look at my feedback regarding the time/space complexity.
# Time complexity: O(n) | ||
# Space complexity: O(n) | ||
def factorial(n) |
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.
👍
# Time complexity: O(n) | ||
# Space complexity: O(n) | ||
def reverse(s) |
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.
👍 However the space & time complexity are O(n^2) because the slice you do has space/time complexity of O(n)
# # Time complexity: O(1) | ||
# # Space complexity: O(1) | ||
def reverse_inplace(s) |
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.
Also you're using the exact method I told you not to use.
# # Time complexity: O(n) | ||
# # Space complexity: O(n) | ||
def bunny(n) | ||
raise NotImplementedError, "Method not implemented" |
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.
👍
# # Time complexity: O(n^2) * not sure about this one | ||
# # Space complexity: O(n^2) * same here? | ||
def nested(s) |
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.
👍 Correct!
# # Time complexity: O(n) | ||
# # Space complexity: O(n^2) | ||
def search(array, value) |
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.
This works, but once again the time complexity is O(n^2)
# # Time complexity: O(n) | ||
# # Space complexity: O(n) | ||
def is_palindrome(s) |
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.
This works, but once again the time complexity is O(n^2)
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!