Skip to content

Commit 21daa34

Browse files
committed
Updates leetcode/binary-search/719-find-k-th-smallest-pair-distance.md
Auto commit by GitBook Editor
1 parent 05e5d66 commit 21daa34

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

leetcode/binary-search/719-find-k-th-smallest-pair-distance.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Here are all the pairs:
1919
Then the 1st smallest distance pair is (1,1), and its distance is 0.
2020
```
2121

22-
**Note:
22+
**Note:
2323
**
2424

2525
1. 2 <= len\(nums\) <= 10000.
@@ -40,8 +40,10 @@ Then the 1st smallest distance pair is (1,1), and its distance is 0.
4040
4. Time complexity O\(nlogn + kLogn\)
4141
5. Space complexity O\(n\)
4242
3. Binary Search
43-
1. Since all numbers are non-negative, the kth distance must be in between \[0, max - min\]
44-
2. We perform binary search on this range until find a distance that has at least k pairs
43+
1. Since all numbers are non-negative, the kth distance must be in between \[0, max - min\], lo and hi respectively
44+
2. We perform binary search on this range until lo and hi merge, and we narrow our search using a separate function count\(mi\), where count\(mi\) return numbers of distances smaller than or equal to mi
45+
3. If count\(mi\) is smaller than k, we have to set lo = mi + 1
46+
4. Else hi = mi
4547

4648
### Solution
4749

0 commit comments

Comments
 (0)