Skip to content

Branches - Sara #34

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

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

Branches - Sara #34

wants to merge 6 commits into from

Conversation

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

You have the 1st method remove_duplicates working, but the minimum prefix isn't working. Also see my notes on your time complexity.

For minimum prefix you need to check to see if a letter matches each string, then if so, add it to prefix, The first letter that doesn't match every other string, you can exit and return prefix.

Let me know what questions you have.

i = 0
while i <= list.length
if list[i] == list[i + 1]
list.delete_at(i)

Choose a reason for hiding this comment

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

Since delete_at shifts all the subsequent elements 1 index to the left, it's an O(n) method. Since you have it in a loop that goes n times this method is O(n2)

return strings[0]
end

total_words.times do |index|

Choose a reason for hiding this comment

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

shouldn't one of these loops go the number of characters in a string, rather than the number of strings times?

You also have an issue with the if statement, you're comparing the wrong things.

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