Find K Closest Elements 🔥🔥 | 3 approaches | Brute + Better + Optimal | Leetcode 658 | C++ | Python

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

Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)

#leetcode
#leetcodeJulyChallenge
#interviewpreparation
Find K Closest Elements solution
Find K Closest Elements Leetcode
Find K Closest Elements C++
Find K Closest Elements C++ Hindi
Find K Closest Elements Hindi

Checkout the series: 🔥🔥🔥
LIKE | SHARE | SUBSCRIBE 🔥🔥😊
Рекомендации по теме
Комментарии
Автор

Hi Ayushi, there is an error in your two pointer approach: at 9:13 you said if(x-arr[i]<arr[j]-x) then j-- else i++. But in 10:03 you are saying if(3-1> 5-3) then i++ else j--; When doing on program using first approach. for [1, 2, 3, 4, 5]
k=4 x=3 the ans is [2, 3, 4, 5] instead of [1, 2, 3, 4]. Could you please post for the two pointer approach.

nagarjunvinukonda
Автор

in the first Max Heap approach, one should take absolute difference, not difference. May try it for this example - eg. {5, 6, 7, 8, 9} K = 3, X = 7. Correct answer is 6, 7, 8 and not 5, 6, 7 which we get via the above approach. Also we need to sort the array in end is using heap in this particular question

BhavyaJain-qzjg
Автор

heap aproach @2:29
two pointer aproach @7:19
binary search aproach @11:32

ravigupta
Автор

I am seeing this video in 2023 and still this video is helpful to many people to understand all the approaches. Thank you Ayushi for your dedication

kshitij_kaithal
Автор

your code is wrong, try submitting in gfg

qehginb
Автор

Prepare before making videos so many flaws.

missionmaths
Автор

well explained. please do provide java code if possible . Thanks.

sssumeet
Автор

your hardwork and efforts are admirable

abhiimali
Автор

Meine bahut lecture dekh liye iss question per meroko smgj nhi aaya yeh question shi se ur iss video mein bhi smj nhi paa raha hoon

MayankRathore-qiqv
Автор

can we take absolute diff in two pointer approach inside if statement

RohitKumar-dygc
Автор

You explained very nicely in detail.... keep it up

ayushichoudhary
Автор

For sure you will reach more subscribers very soon
Once 1k subcribers is reached growth will be expontial for sure 🔥🔥🔥

ravulaakhilsurya
join shbcf.ru