返回题库|

得分最高的单词集合

中等美团

得分最高的单词集合

中等美团回溯

题目描述

给定一个单词列表 words 和一个字母数组 letters(每个字母只能使用一次),以及每个字母的得分数组 score。从 words 中选择一个子集,使得子集中所有单词使用的字母都不超过 letters 中对应字母的数量,且总得分最大。返回最大总得分。

示例

输入:words = ["dog","cat","dad","good"], letters = ["a","a","c","d","d","d","g","o","o"], score = [1,0,9,5,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0]
输出:23
solution.ts
输出结果
点击「运行代码」按钮查看结果...