Previous Greater Element Leetcode Javascript Question