How do you solve this problem in O(n) time?
Given an unsorted array of integers, design algorithms to transform the array such that the integers are replaced by the nearest bigger integer on their right. If there is no bigger integer on its right, the integer remains the same. For example, the following array of integers
2 1 4 5 3 6 7 9 4 8
should become
4 4 5 6 6 7 9 9 8 8