Skip to content

Conversation

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

These methods work, but see my comments on the time complexity. Let me know if you have questions or if I can clarify a bit.

Well done!

list.each_with_index do |value, index|
if index > 0
if value == list[index - 1]
list.slice!(index)

Choose a reason for hiding this comment

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

Slice is going to shift subsequent elements to the left one index. Thus it as a time complexity of O(n). Inside this loop your method as time complexity of O(n2)


# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n)

Choose a reason for hiding this comment

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

Since you have those two nested loops you actually have a time complexity of O(n2)

end
return min_string if commons.length == strings.length

until hi <= low

Choose a reason for hiding this comment

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

Since you never change low, you may not need it. This made me think of binary search and it confused me for a bit.

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