LeetCode Username
NDR0216
Problem Number, Title, and Link
- 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