-
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
Rachael Water #41
base: master
Are you sure you want to change the base?
Rachael Water #41
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.
As you noted you didn't finish all the methods, however the methods you do have complete are mostly working. Take a look at my comments especially regarding ways to do reverse_inplace and how to make the time and space complexities better.
# 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.
👍 Given how you have the # frozen_string_literal: true
which makes the string fixed and means the slice isn't recreating the string.
# Time complexity: O(n) | ||
# 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.
Just noting this is incomplete.
# 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.
This doesn't work see below
2 * bunny(n-1) | ||
return |
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.
2 * bunny(n-1) | |
return | |
return 2 + bunny(n-1) |
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
Just noting this is incomplete.
# Time complexity: ? | ||
# Time complexity: O(n) | ||
# Space complexity: ? | ||
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.
# 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.
👍 , but can you see any way to adjust this to be O(n)?
def digit_match(n, m, num_matches = 0) |
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 this is incomplete.
I'm going to have my software developer brother-in-law explain these to me and hopefully have them updated with the correct answers after.