Maximize weighted subsequence pairs with wildcards | Amazon Coding Question