One of the 2 coding questions was like : given an array, print a new array of the same size in which elements corresponds to the first greater element towards right in the given array for each of the elements in the given array. If there is no greater element , the element should be -1.
For example:
Given array:
[7,8,9,20,5]
Answer:
[8,9,20,-1,-1]
Later , I was asked to optimize it , but I couldn't not optimize it.