Skip to content

Conversation

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

Nice work, both methods do the job. Do see my note on the time complexity of delete_at.

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.

delete_at shifts all subsequent elements left one index each. This is an O(n) method. Since it's nested inside a loop running n times, this means the method is an O(n2) algorithm.

# Space Complexity: ?
# Time Complexity: O(nm) - depends on the length of strings = n and length of string[0] = m
# Space Complexity: O(m) - is reacreting a result total
def longest_prefix(strings)

Choose a reason for hiding this comment

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

Well done.

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