Next Greater Element I Leetcode Javascript Question