implement solution to SubsetSumMax and WordDistance