Minimum Array End Leetcode Solution Python