LeetCode
Next Greater Element I
Click
here
for an explanation.