algorithms.tutorialhorizon.com

Find no of reverse pairs in an array which is sorted in two parts | Algorithms

Given an array of integers A[] which is sorted in two parts (both parts are individually sorted), find no of reverse pairs means no of (i, j) pairs where i belongs to the part one and j belongs to part 2 and A[i]>A[j]. Example: A[] = {4, 6, 8, 9, 1, 5, 10, 11} Output: 7 Explanation: Part one: {4, 6, 8, 9} Part two: {1, 5, 10, 11} Reversed pairs: (4, 1) (6, 1) (6, 5) (8, 1) (8, 5) (9, 1) (9, 5) = 7