Skip to content
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 - Linnea #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Branches - Linnea #49

wants to merge 1 commit into from

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

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