Skip to content

Conversation

@emaust
Copy link

@emaust emaust commented Sep 17, 2019

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! See my notes on the time complexity, but your methods work. Well done!

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

Choose a reason for hiding this comment

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

delete_at shifts each subsequent element left by one index. So that's an O(n) method. Since you have it nested in a loop running n times, remove_duplicates becomes an O(n2) method.

if prefix[i] != comparison_word[i]
i -= 1
prefix = prefix[0..i]
if prefix == original

Choose a reason for hiding this comment

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

How could this if statement be true given the line above.

# Space Complexity: ?


# Time Complexity: O(n * m)

Choose a reason for hiding this comment

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

Correct

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