Flipkart interview question

find the next greatest element in an array