Minimum Sum Partition Leetcode Solutions Python