-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: master
Are you sure you want to change the base?
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.
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) |
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.
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) |
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 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 |
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 you never change low, you may not need it. This made me think of binary search and it confused me for a bit.
No description provided.