The task is to find the minimum possible sum of absolute difference of pairs formed by pairing each element of array a[] with an element of b[]. Each element of each array can be considered only once. The problem can be efficiently solved by using the concept of dynamic programming using the following idea.
Sort: