Very nicely explained, clarity in your voice. This code is easy to understand than GFG solution. Good job!
@arijitdey84192 жыл бұрын
Very nicely explained..keep up the good work and keep coming up with such videos,and of course thanks a ton
@sougatoghosh84672 жыл бұрын
such logics are hard to build. hatsoff
@rishukumarsingh3926 Жыл бұрын
I understood the approach, but i don't get that, what lead to this approach, what is the thought process behind appraching this question in this ways, when i was solving it, i made it complicated by observing dependencies of position in terms of graph!
@thewonderboy-k9x3 ай бұрын
LET CASE 1: Bhai agr kisi array ko sort krna h toh number of swaps btane hain. LET CASE 2: Maan le tune uss array ko sort kr diya ab tu chahta h uss array ko wapas se original array m convert krna . Dono case m swaps ka answer same hoga. BASS LOGIC YAHI H. TRACK KRTE JAA RAHE HAIN CORRECT POSITION KYA HONI CHAHIYE SORTED ARRAY MEIN
@yuvrajagarkar8942 Жыл бұрын
thank you for putting so much efforts, worth the time 👍
@barathnatarajan85662 жыл бұрын
Beautiful explanation So clear!
@kaushikvelidandla70102 жыл бұрын
Why is the result minimal ? That explanation is not clear. Might be better to explain using dependency graph and connected components
@vamshisamineniz59052 жыл бұрын
good selection of questions
@MritunjayKumar-rd2es2 жыл бұрын
this was the best explaination
@pratube48462 жыл бұрын
Irony is that, this cannot be solved without sorting the array 😂
@vivekshrivastav36742 жыл бұрын
it can be done but that method will take O(n^2) time complexity. Selection sort
@aj.anshuljohri Жыл бұрын
@@vivekshrivastav3674 You can optimize the selection using map. I did this, it worked, and it's O(nlogn). int minSwaps(vector &num) { // Code here map mp; int ans = 0; int n = num.size(); for (int i = 0; i < n; i++) { //assigning index to its value mp[num[i]] = i; } for (int i = 0; i < n; i++) { //extracting minimum element auto pr = *mp.begin(); int mini_ele = pr.first; int mini_ele_ind = pr.second; if (mini_ele_ind != i) { //swapping current element index with //minimum element index mp[num[i]] = mini_ele_ind; swap(num[i], num[mini_ele_ind]); ans++; } //erasing the minimum element as it's processed mp.erase(mp.begin()); } return ans; }
@rishikeshmishra715 Жыл бұрын
Nice explanation !
@sangamchoudhary69773 жыл бұрын
fantastic 🔥
@learnwithayush7838 Жыл бұрын
😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍 Very Nice Explanation . And you are also very beutifull😁😁😁😁
Thanks, but how can we claim this approach always guarantee the correct ans? Is there some intuition behind it?
@anshulkumarneekhara93777 ай бұрын
correct. What is the intuition behind this approach??
@hardcash9930 Жыл бұрын
in which company are you placed now and with what approx package? (you are great motivation)
@Anonymous____________A7212 ай бұрын
Microsoft CTC 50lakhs
@ashokdurunde18142 жыл бұрын
very nice explanation thank you very much
@pk4288 Жыл бұрын
what if there are repeated elemets
@aryansiroyajain85032 жыл бұрын
Let me just ignore it was the best part😄
@somnathmore10822 жыл бұрын
Thank you didi,clear my doubt
@manojnavinjamuri58672 жыл бұрын
Thank you Alisha
@piyushbhagwat3119 Жыл бұрын
Thank you!
@techstuff98302 жыл бұрын
How can we tackle this if duplicates are allowed?
@kirankutte70732 жыл бұрын
Will this appraoch work for if elements are from 0 - N-1
@shreyamaheshwari73292 жыл бұрын
Mam how do we make sure its the minimum number of sorts which we had found
@bhaskarmishra84792 жыл бұрын
yeah... how do we guarantee that this would be the min no. of swaps
@T_tintin Жыл бұрын
I think it's probably the minimum no of swaps becoz we r sorting the array and we already know the correct positions of the elements and we r placing them there only . It's the best thing we can do .Put them where they should be with one swap only. And if they r already there don't swap.
@anshulkumarneekhara93777 ай бұрын
What is the intuition behind this approach??
@abc-ym4zs Жыл бұрын
madam i have one doubt when i have seen in solution in discussion section i am not able to understand but after watching your youtube solution i understood so why this happens i am always depending on yt videos how to overcome this i am not able to improve problem solving
@dhananjoydey13372 жыл бұрын
thanks
@AmanSharma-vb5jl3 жыл бұрын
🔥
@smartwork7098 Жыл бұрын
Thanks
@prathammittal64213 ай бұрын
do this method have a name ? if it is pls tell the name
@rishabhgupta9846 Жыл бұрын
good video
@Jitendrakumar-gb7cn2 жыл бұрын
I came here to see graph approach why using wrong thumbnail , but your approach is pretty much hint to the graph approach
@systemforge2 жыл бұрын
Woah.. how to come up with ideas like this...
@alexrcrew19752 жыл бұрын
one day her browser is gonna crash in between the tutorial .. so many tabs are opened haha
@harshits-1195 Жыл бұрын
Can anybody Tell me What if there are duplicate elements in vector
@debashishghosh45492 жыл бұрын
Can somebody tell me the difference between the number of inversion count question and this one.
@apk73732 жыл бұрын
Use a better writing board like microsoft whiteboard or any similar... The one you are using is worse. But the explanation is amazing
@deepakjainseth81262 жыл бұрын
alisha aap 1x ke speed mey bola karo
@Ninja-yt2qs2 жыл бұрын
Very confusing, no need to complex the simple things