-
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
India - Water #36
base: master
Are you sure you want to change the base?
India - Water #36
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.
Overall nice work India. You hit the main learning goals. Check out my comments especially regarding the reverse_inplace method.
# 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: ? | ||
# Space complexity: ? | ||
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.
👍 Time & space complexity?
# Time complexity: O(n^2) | ||
# Space complexity: O(n^2) | ||
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.
⚠ This method is not reversing the string in place, instead it's creating a new string with each recursive call.
Could you see a way to do it with the following method signature?
# Time complexity: O(n^2) | |
# Space complexity: O(n^2) | |
def reverse_inplace(s) | |
# Time complexity: O(n^2) | |
# Space complexity: O(n^2) | |
def reverse_inplace(s, low = 0, high = s.length - 1) |
# Time complexity: O(n) | ||
# Space complexity: O(n) | ||
def bunny(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^2) | ||
# 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.
👍 However can you see how to do this method with O(n) space/time complexity?
return false | ||
else | ||
return is_palindrome(s[1..-2]) | ||
end | ||
end | ||
|
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.
Just noting the incomplete methods.
# Time complexity: O(n^2) | ||
# Space complexity: O(n^2) | ||
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.
👍 Similar note to the above on time/space complexity.
No description provided.