Skip to content

Conversation

@qqdipps
Copy link

@qqdipps qqdipps commented May 28, 2019

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.

Outstanding, you had nearly all the methods done in ideal time complexity and had pretty accurate Big-O predictions. You hit all learning goals.

def reverse(s)
raise NotImplementedError, "Method not implemented"
return "" if s.empty?
return s[-1] << reverse(s[0...-1])

Choose a reason for hiding this comment

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

Technically s[0...-1] creates a new string of length n-1, so this algorithm is actually n^2

# Space complexity: ?
def reverse_inplace(s)
raise NotImplementedError, "Method not implemented"
# Time complexity: O(n) where is the number of chars in the string

Choose a reason for hiding this comment

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

👍

def nested(s, left = 0, right = nil)
right ||= s.length - 1
return true if left >= right
return false if s.length.odd? || s[right] == s[left]

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