-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: master
Are you sure you want to change the base?
Branches - Sara #34
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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| |
There was a problem hiding this comment.
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.
No description provided.