New function in stack:

    check the next greater element and print them in O(n) time.