Maximize weighted subsequence pairs with wildcards | Amazon Interview Question