Copy next larger element in an integer array (faster method)

Adding an O(n) solution.