Monotonic Array Leetcode Solution Python