Skip to content

Conversation

@kanderson38
Copy link

No description provided.

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.

Very nicely done. See my inline comments, but this is outstanding work. Check a little bit on your big-O as you missed some of the overhead of some of the built-in functions, something most people do.


# Time complexity: ?
# Space complexity: ?
# Time complexity: O(n), where n is the length of the string

Choose a reason for hiding this comment

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

This is not in place since you create a new string.

Think about making a helper which takes the string, a left index and right index. The base case is when left_index >= right_index Each recursive call you swap the characters at left_index or right_index and then make a recursive call with the string, and left_index + 1 and right_index -1.

return reverse_helper(s, i, j)
end

def reverse_helper(s, i, j)

Choose a reason for hiding this comment

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

Really great!

# Space complexity: ?
# Time complexity: O(n), where n is the input number
# Space complexity: O(n), where n is the input number
def bunny(n)

Choose a reason for hiding this comment

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

👍

# Space complexity: ?
# Time complexity: O(n), where n is the size of the input string
# Space complexity: O(n), where n is the size of the input string
def nested(s)

Choose a reason for hiding this comment

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

👍


end

# Time complexity: O(n), where n is the length of the input array

Choose a reason for hiding this comment

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

This is actually O(n^2) since you create a new array with each recursive call.

# Space complexity: ?
# Time complexity: O(n), where n is the length of the string
# Space complexity: O(n), where n is the length of the string
def is_palindrome(s)

Choose a reason for hiding this comment

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

👍

# Space complexity: ?
# Time complexity: O(log10(n)), where n is the smallest input number
# Space complexity: O(log10(n)), where n is the smallest input number
def digit_match(n, m)

Choose a reason for hiding this comment

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

👍

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