Any one gave me approach for NEXT GREATER ELEMENT III

let’s assume you have array of length n you have to find next greater element of every element but the element you find for next greater element is closest distance compare to other greater element of that element (its a circular array)
let understand with example -:
int [] arr = [1,5,3,8,6,9,4]
output - [3,6,4,9,8,-1,5]

int [] arr = [1,6,5,4,9,2,3,8]
output -: [2,8,8,5,-1,3,4,9]

What are the problem constraints, can you link the problem?

problem was asked in interview
after a interview when I search then I find the same problem
link below

Could you explain the question clearly.
Or,could you give a sample explanation?

refer a link