Skip to content

[BUG] - [719. Find K-th Smallest Pair Distance] time complexity isn't accurate enough #23591

@NDR0216

Description

@NDR0216

LeetCode Username

NDR0216

Problem Number, Title, and Link

  1. Find K-th Smallest Pair Distance https://leetcode.com/problems/find-k-th-smallest-pair-distance/

Bug Category

Editorial

Bug Description

In Approach 2, the time complexity of "Populate the prefixCount array" is O(M), but it isn't included in the total time complexity.
Therefore, the total time complexity of Approach 2 should be O(nlogn+nlogM + M)

Populate the prefixCount array:

Iterate through possible distance values from 0 to maxPossibleDistance - 1.
For each distance value, determine the number of elements in the array nums that are less than or equal to this distance.
Store this count in prefixCount for the current distance.

Language Used for Code

None

Code used for Submit/Run operation

No response

Expected behavior

Approach 2
Time complexity: O(nlogn+nlogM + M)

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions