Python Time Monotonic Stack Leetcode