Solution to Inverse Pairs from Jobdu

6 Sep

Question (in Chinese):

Question Name: Inverse Pairs

Question Description: Given an integer array, for any two numbers, if the former one is less than the latter one, they are an inversion pair. Compute the total count of inversion pairs in the given array.

Input: the input might contain multiple test cases. Each test case contains two lines. The first line includes only one integer N (1 <= N <= 10^5), saying the number of elements in the test array. The second line includes N integers as the content of the array.

Output: for each test case, print out the number of inversion pairs.

One same challenge as one from Codility. The solution is:

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!