Reverse pairs


@Tanvi09 the linear memoization would not give the correct answer. Let us take an example to understand: Let the array be A: 8 6 2 1 4 3 2. Here, the minimum numbers upto the current index are stored in min: 8 6 2 1 1 1 1. We will now move linearly over the array: ans=0 for 8. ans=0 for 6. ans=2(we add 2 since min[1]>2A[2] ). Now, for 1, (min[2] is not greater than 2A[2]), so, we cannot increment the ans. But, we see that {8,1} and {6,1} should have be counted. If we need to account for them, we need to check for min[1]. Since, we require to move back the array, the approach becomes O(n^2).