Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Rachael Water #41

wants to merge 1 commit into from

Conversation

RachaelGomez
Copy link

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.

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.

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.

Comment on lines +5 to 7
# 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.

👍 Given how you have the # frozen_string_literal: true which makes the string fixed and means the slice isn't recreating the string.

Comment on lines +25 to 27
# Time complexity: O(n)
# 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.

Just noting this is incomplete.

Comment on lines +31 to 33
# Time complexity: O(n)
# Space complexity: O(n)
def bunny(n)

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

Comment on lines +37 to +38
2 * bunny(n-1)
return

Choose a reason for hiding this comment

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

Suggested change
2 * bunny(n-1)
return
return 2 + bunny(n-1)

Comment on lines 45 to 47
# Time complexity: ?
# Space complexity: ?
def nested(s)

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.

Comment on lines -33 to 59
# Time complexity: ?
# Time complexity: O(n)
# Space complexity: ?
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 isn't a recursive method!

Comment on lines +72 to 74
# Time complexity: O(n^2)
# Space complexity: O(n^2)
def is_palindrome(s)

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)

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.

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