Skip to content

Do not insert at the beginning of a list #7

@progval

Description

@progval

If in a loop you will only add items at the beginning of a list (L.insert(-1, x)); use a temporary list, append items to it, and reverse it.
Linear complexity instead of quadratic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions