Skip to content

Inaccurate time complexity requirement for "Kth Largest Integer in a Stream" #5243

@sebastiancarlos

Description

@sebastiancarlos

On https://neetcode.io/problems/kth-largest-integer-in-a-stream

The requirements are:

You should aim for a solution with O(m log k) time and O(k) space, where m is the number of times add() is called, and k represents the rank of the largest number to be tracked (i.e., the k-th largest element).

It doesn't account for the cost of the constructor, which has to be at least time O(n) to process every input element.

Given that the requirements already considers the full runtime (given that m is the number of calls in a test case), it might be confusing if it doesn't explicitly excludes the construction time.

My suggestion would be to just add a separate time complexity for the constructor.

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