Given a list of elements, you can remove either left or right element and add this to a new list either as first element or last element. You have to do this to form a new list such that inversions are minimized. (inversion means l [i] > l [j] for i<j). How to approach this problem efficiently?