Contiguous Array Leetcode Solution Python