-
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 - Kayla Johnson #39
base: master
Are you sure you want to change the base?
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.
You didn't quite finish them all and you didn't manage to do reverse in place. However the other methods are pretty well done although several lack space/time complexity. Take a look at my comments and let me know what questions you have.
# Time complexity: O(n) ['n' being the number of times factorial computation has to be implemented until n reaches 0] | ||
# Space complexity: 0(n) ['n' being the number of function calls on the stack] | ||
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^2) | ||
# Space complexity: O(n^2) | ||
def reverse(s, i = 1) |
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.
👍
lib/recursive-methods.rb
Outdated
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
# Time complexity: ? | |
# Space complexity: ? | |
def reverse_inplace(s) | |
# Time complexity: ? | |
# Space complexity: ? | |
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.
👍
lib/recursive-methods.rb
Outdated
# 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.
👍 Time/space complexity?
lib/recursive-methods.rb
Outdated
# Time complexity: ? | ||
# Space complexity: ? | ||
def search(array, value) | ||
raise NotImplementedError, "Method not implemented" | ||
def search(array, value, i = 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.
👍 Time/space complexity?
lib/recursive-methods.rb
Outdated
puts "Sorry, I couldn't figure this one out!" |
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.
Understood, does this help?
puts "Sorry, I couldn't figure this one out!" | |
if n == 0 || m == 0 | |
return n % 10 == m % 10 ? 1 : 0 | |
end | |
new_n = n / 10 | |
new_m = m / 10 | |
if n % 10 == m % 10 | |
# your code |
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.
Nice work Kayla, thanks for getting this in. This is outstanding work. Take a look at my comments and let me know what questions you have.
# Time complexity: O(n) -still has to iterate over every element in string | ||
# Space complexity: O(n) -stack can get very large if string is big | ||
def reverse_inplace_helper(s, start, finish) |
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.
👍 Really nice!
# Time complexity: O(n) | ||
# Space complexity: O(n) | ||
def digit_helper(n, m, match = 0, place = 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.
👍 Outstanding!
# Time complexity: O(n) best case O(1) if item is in index 1? | ||
# Space complexity: O(n) best case O(1) if item is in index 1? | ||
def search(array, value, i = 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.
👍 Well done!
# Time complexity: O(n) | ||
# Space complexity: O(n) | ||
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.
Due to the slice you're doing, this is O(n^2) for both time/space.
Otherwise 👍
# Time complexity: O(n) - traversing the whole string | ||
# Space complexity: O(n) -traversing the whole string | ||
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.
Due to the slice this is O(n^2), but otherwise 👍
No description provided.