Find K-th Smallest Pair Distance | LeetCode 719 | Coders Camp

preview_player
Показать описание

This video explains the solution for "Find K-th Smallest Pair Distance" using Binary Search logic.

#LeetCode #whiteboardexplanation #coderscamp #binarysearch #codinginterview
Рекомендации по теме
Комментарии
Автор

Thank you very much for your explanation! I struggled for several hours to understand the related article in the Leetcode editorial but it was in vain. Then I found your video and got the idea after the first watch. So simple and clear explanation!

fbrfjdp
Автор

You made a mistake at 6:34, it should be 7- 9 and the mid is 8

algorithmo
Автор

you have written hight instead od right and ur code accepted wow i dont know how it happended but i should give u all right code class Solution {
public int smallestDistancePair(int[] nums, int k) {
Arrays.sort(nums);
int left=0;
int
while(left<right){
int mid=(left+right)/2;
if(issmallpairs(nums, k, mid)) right=mid;
else left=mid+1;
}
return left;
}
private boolean issmallpairs(int[] nums, int k, int mid){
int c=0; int left=0;
for(int
left++;
c+=right-left;
}
return (c>=k);
}
}
btw explanation was relly appreciating

AnshulKotwal-ro
Автор

Thankyou sor much for this video👍, your explanation is superb 😀

Anjaliartistp
Автор

Please keep making more leetcode videos!

algorithmo
Автор

This is what an algorithm walk is called Really Nice

jawwadakhter
Автор

first: you calculated 'mid' wrong in the example
second: Please try to give your own explanation instead of just copying and explaining code taken from discussion

ArpitDhamija