Skip to content

Bug Report for simplify-path #5522

@AnonymousAnion

Description

@AnonymousAnion

Bug Report for https://neetcode.io/problems/simplify-path

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

The first proposed solution has O(n^2) runtime due to the use of naive string concatenation e.g. cur += c. Don't forget that strings are immutable so naive concatenation is an O(n) operation and since this is within a for loop - that is O(n) - the overall solution becomes O(n^2). Therefore, the second solution should be strongly preferred!

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