Next greater of the next smaller

Problem Name:
Next greater of the next smaller
Site:HackerEarth
Links:
Tags: