Leetcode Monotonic Stack Python Problem Solving