I'm trying this problem and solved it by myself by taking count as global variable.. But you taught us in a vary optimal way without taking count as a global variable. Really best optimal approach. Thankyou ❤
Finally completed this recursion playlist and Thanks a lot striver for great explanation throughout and patiently drawing recursion tree. patience is the key to solve and teach anything . And you have it man and you are teaching that too. Thanks a lot again
If u don't wanna use cnt in mergeSort function, you can do this:- int mergeSort(vector &arr, int low, int high) { if (low >= high) return 0;
int mid = (low + high) / 2 ; int left = mergeSort(arr, low, mid); // left half int right = mergeSort(arr, mid + 1, high); // right half int m = merge(arr, low, mid, high); // merging sorted halves return left + right + m; }
Can we realistically solve this if it comes in an interview given we haven't solved it before? I mean how do can you get the intuition of merge sort from this problem? I really don't get it.
// Everytime while sorting you move an element to the left (assume nobody moves to right agar chote walo ko aana hoga to left me aa jayenge) // if an element crosses another element while moving to the left for the purpose of sorting then it should increase the count of inversion
Global vs Local In Global variables values updated dynamically but in local variables we need to pass updated values (manually) to subsequent functions
Please watch our new video on the same topic: th-cam.com/video/AseUmwVNaoY/w-d-xo.html
this link take u to the same video we are watching
@@namannema3349 thats what recursion means
@@yogeshkaushik8316 😆
Nowadaya strivers voice has become so calm and soft 😅❤
True...as compared to his previous vdos 😂
😂
@@anuradha3868 same thought 😂
abe mic kharap tha pehle😂
Best count inversion video on TH-cam, your method of teaching is very best that it gets me understand very easily 🌟🌟🌟
I'm trying this problem and solved it by myself by taking count as global variable.. But you taught us in a vary optimal way without taking count as a global variable. Really best optimal approach. Thankyou ❤
whats the complexity of your solution?
can you share it?
@@bishakhdutta8427 same as merger sort merge algorithm
Making the complex problem looks simpler is a kind of skill that striver only has🛐
this is the best playlist in world. thank you stiver for your effort.
Striver your voice is very soothing and calm bro ❤.... I use it to sleep at night AND study... and I don't feel sleepy
The best count inversion video on TH-cam.. Thanks a lot Raj.. stay blessed❤
Completed the playlist. This was the best recursion playlist I ever went through. Thanks a lot Striver.
Understood! Super amazing explanation as always, thank you very very very much for your effort!!
Finally completed this recursion playlist and Thanks a lot striver for great explanation throughout and patiently drawing recursion tree. patience is the key to solve and teach anything . And you have it man and you are teaching that too. Thanks a lot again
I am happy with the brute force now I will see optimal 1 week before interview bcz University exams are in this month
Did anyone ask you?
I usually don't comment but wanted to say that just subbed your channel. This is the best explanation I've ever got. THANKS A LOT:>)
Understood
THE BEST EXPLANATION
Excellent playlist 👌 👏 ❤
If u don't wanna use cnt in mergeSort function, you can do this:-
int mergeSort(vector &arr, int low, int high) {
if (low >= high) return 0;
int mid = (low + high) / 2 ;
int left = mergeSort(arr, low, mid); // left half
int right = mergeSort(arr, mid + 1, high); // right half
int m = merge(arr, low, mid, high); // merging sorted halves
return left + right + m;
}
such an awesome expalination bhaiya just approach dekhkr hi dimag ma intution agya ki merge ma kase implement krenge , you are best
As usual your teaching jus made coding much easier than it is bruh!! Waiting for Binary Search series bruh!!!!
thanks sir for making this wonderful video sir !!!
Can we realistically solve this if it comes in an interview given we haven't solved it before? I mean how do can you get the intuition of merge sort from this problem? I really don't get it.
no way bro
Exactly my thought, No way you gonnna come up with something like that on your own
good explanation on count inversion
So much crystal clear!!!!Thank youu❤
OMG Bawal explanation Striver Bhaiya.😃
Understood ❤ At last
Timestamps:
---------------------
00:40 Problem Statement
02:11 Brute force approach
02:52 Pseudocode
03:35 Complexity
04:05 Optimmal solution
04:22 Intuition
10:33 Approach + Dry-run
18:02 Code
22:37 Complexity
Best teaching approach so far!!!!
This is the best explanation I've ever got.
i just imagine if all the problems would be available on this channel in future
I was struggling with the solution but as soon as you mentioned merge sort it clicked in my mind
your problem solving approach explanation is superb
Understood it very well
Thanks for this amazing series
thanks striver for making a complex question into very easy question
🤗
Amazing I solved two questions using the same logic.
Best explanation ever for this problem
understood!!!
Thoroughly enjoyed the problem!!
Thank You Bhaiya
Happy teacher day 🎉❤
UNDERSTOOD SIR ! GREAT EXPLAINATION
Superb logic, Understood!!!
// Everytime while sorting you move an element to the left (assume nobody moves to right agar chote walo ko aana hoga to left me aa jayenge)
// if an element crosses another element while moving to the left for the purpose of sorting then it should increase the count of inversion
just wow explanation
understood!
def merge(arr,l,mid,h):
temp=[]
i=l
j=mid+1
cnt=0
while i
Hey, can you make a video on binary insertion sort and compare it's time complexities with insertion sort. Thanks for your videos on DSA.
The way he said wow! Uff in love with the voice
didn't understand much but will try again
Understood amazing explanation
Best explanation ever
understood the approach sir
thanks alot
Really it was a great series Striver.🔥🔥
loved the optimal solution, intuition op!
Thank you for this video !!
Understood, thank you.
Great explanation!!
awesome as always!!!!🤩
very nice explanation bhaiya
Global vs Local
In Global variables values updated dynamically but in local variables we need to pass updated values (manually) to subsequent functions
thank you so much for watching
UNDERSTOOD;
Understood Sir🥳
All i can say is Thankyou so much ❤🙌
Great video
understood Bhaiya!!
Understood.
Understand bhaiya
Superb Explanation
very nice video
Nice lecture................
Badhiya kaam kar rahe ho, see you soon
understood
Thank you😊
loved that bhaiya
thanks alot bhaiya
understood.
Understood :)
understood
I understood the problem
thank u striver
Understood 🎉
Understood✅🔥🔥
Understood
These types of questions always demotivate me... like how you can think of such kind of solution in an interview
so aweesome
Understood!
Understood🔥
13:05 the kind of excitement I want while learning DSA.
understood :)
thanks mate
Understood brother❤️
Understood sir
Understood thats great...
awesome
Understood, but I am gonna need some time to implement this.
Implemented.
Thanks 😊👍
UNDERSTOOD
Understood!
understood 👍👍
Understood sir
Understood...!!!!
Thanks
Thank u bhai