Skip to content

Conversation

@llinneaa
Copy link

@llinneaa llinneaa commented Oct 7, 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.

Thanks for getting this in. Take a look at my comments and let me know if you have any questions. Some things to work on here.

Comment on lines +12 to +14
if list[i] != i
new_list << list[i]
end

Choose a reason for hiding this comment

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

This is only not adding elements if they are not equal to their index, which won't work in all cases.

Consider:

   it "will remove duplicates for even longer arrays " do
      expect(remove_duplicates([1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4])).must_equal [1, 2, 3, 4]
    end


# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n^2)

Choose a reason for hiding this comment

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

This is actually O(nm) where m is the length of the shortest word.

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n^2)
# Space Complexity: O(n)

Choose a reason for hiding this comment

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

Given the above space complexity is O(m)

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