Excellent explanation! This is the BEST explanation of how to count inversions using a merge sort type algorithm that I have found!
@mishkamn5 жыл бұрын
Very good straight to the point and clear
@shahkushal14954 жыл бұрын
If courses are bollywood, NTPEL is the Irfan Khan of it.
@dejavukun4 жыл бұрын
Thanks a lot sir!
@AbhishekChaturvedi74 жыл бұрын
superb explanation
@0anant04 жыл бұрын
Very nice explanation. Leetcode 493 is based on this.
@pranavyeleti34993 жыл бұрын
sir countR,R should be mergesortcount(A,mid+1,right).i have a dought.correct me if i am wrong
@cowboymc82304 жыл бұрын
What I don't understand is the part : sort and count inversions in L and R. I mean since you sort L and R already, the count of inversions in either L or R would be 0, isn't it?
@0anant04 жыл бұрын
Those recursions occur during the "merge" portion of the L and R halves. The very act of sorting L and R involves 'merge' e.g. cInv += mergeSort(lo to mid)