Skip to content

Conversation

@criacuervos
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.

Not bad, you do have some issues with space complexity and one bug in the matching parens, but nice work overall.

# Space complexity: ?
# 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.

👍

raise NotImplementedError, "Method not implemented"
# Time complexity: O(n)
# Space complexity: O(1)
def reverse_inplace(s, i = 0, j = -1)

Choose a reason for hiding this comment

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

The space complexity is O(n) due to the system stack

raise NotImplementedError, "Method not implemented"
# Time complexity: O(n)
# Space complexity: O(n)
def bunny(n, ears = 0)

Choose a reason for hiding this comment

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

This works although I was expecting something like:

def bunny(n)
  return 0 if n == 0 
  return 2 + bunny(n-1)
end

if s.length.odd?
return false
elsif low < high
if s[low] != "(" && s[high] != ")"

Choose a reason for hiding this comment

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

Small bug

Suggested change
if s[low] != "(" && s[high] != ")"
if s[low] != "(" || s[high] != ")"

# 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.

👍


# Time complexity: O(n)
# Space complexity: O(1)
def is_palindrome(s, i = 0, j = -1)

Choose a reason for hiding this comment

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

👍 But the space complexity is O(n)

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