Inversion Count

This code will fail if there duplicates in the array
There is a same question on leetcode which doesnt work if we use this logic

Hey @aryamaan1011
How can I help u?

Hey,I have been solving a question based on Inversion count using the concept shown in the video…but i am getting the wrong answer…

This is a question from leetcode:-https://leetcode.com/problems/reverse-pairs/
https://ide.codingblocks.com/s/329765 here is the code i have written…but i guess it fails when there are duplicates in the array…it passes the second test data given but not the first one…plz help rectify the code

Hey @aryamaan1011 Yup u are right this modification is failing for that question.
See last solution on https://leetcode.com/problems/reverse-pairs/solution/ to see what merge sort modification will work

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.