Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug Report for k-closest-points-to-origin #4881

Open
@skhoshnood

Description

@skhoshnood

Bug Report forhttps://neetcode.io/problems/k-closest-points-to-origin

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

The time complexity of the Min-Heap solution seems to be wrongly mentioned as O(klogn).
The correct time complexity is O(n + k
logn). The reason is that the solution includes two different steps, first the min-heap building step which contains n append operations to the min-heap, which will be n * O(1) = O(n) and then a heapify, which will also be O(n). So, getting the min-heap ready initially, has a time complexity of O(n). The second step of the solution entails k times popping from the heap, which will be O(klogn). The O(n) part is significant and cannot be omitted. The total time complexity comes out to O(n + klogn)

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp