Array Partition Leetcode Solution Python