You call THAT divide and conquer? You clearly have no idea what divide and conquer is. Learn that again then come back and ask later.
Small tip: This code is O(N ^ 2), not NlogN.
I understand , count function , is called ‘n’ times, and each time loop inside count function depends on size of ‘n’ and atmost runs in O(n).
BUT
I don’t understand ,on using standard Merge function( to combine sorted halves) instead of count function, how overall complexity reduces to nlogn. Merge function is also called ‘n’ times right( same as count function) and dependent on length of input.
I never use divide conquer in calculating inversions anyways, so if you want an insight on how the algorithm itself works you will have to search by yourself. This post is more of a “I don’t know how merge sort can be used to solve this task” than “This solution is O(nlogn) and it TLEs” now, just do some research.