Copy next larger element in an integer array

O(n^2) solution at present. Can be done more efficiently. Looking into
it.