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

Branches - Emily Ball #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Branches - Emily Ball #30

wants to merge 2 commits into from

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)

end

# 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