Skip to content

Speed up LinkedHashMap remove() function to O(1) #178

@chaitanya0411

Description

@chaitanya0411

LinkedHashMap is currently implemented using a combination of map and Doubly Linked List but takes O(n) time to remove an element. The implementation should use a reference to the node in the doubly linked list where the element is stored and should be removed in O(1). Also, the remove method first tries to find the index in O (n) and then remove the element in O(n). It can be easily optimized to do it in O(n).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions