LeetCode
Next Greater Element II
Click
here
for an explanation.