Next Smallest Element Leetcode Problems Python