Leetcode Monotonic Stack Python Programs Using Functions