Next Smaller Element Leetcode Javascript Question