1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-24 14:28:56 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-10-07 21:03:28 +08:00
parent b43009ddf3
commit ee13c73307
59 changed files with 18268 additions and 12348 deletions

View File

@@ -0,0 +1,42 @@
力扣嘉年华同样准备了纪念品展位,参观者只需要集齐 `helloleetcode``13` 张字母卡片即可获得力扣纪念章。
在展位上有一些由字母卡片拼成的单词,`words[i][j]` 表示第 `i` 个单词的第 `j` 个字母。
你可以从这些单词中取出一些卡片,但每次拿取卡片都需要消耗游戏代币,规则如下:
- 从一个单词中取一个字母所需要的代币数量,为该字母左边和右边字母数量之积
- 可以从一个单词中多次取字母,每个字母仅可被取一次
> 例如:从 `example` 中取出字母 `a`,需要消耗代币 `2*4=8`,字母取出后单词变为 `exmple`
再从中取出字母 `m`,需要消耗代币 `2*3=6`,字母取出后单词变为 `exple`
请返回取得 `helloleetcode` 这些字母需要消耗代币的 **最少** 数量。如果无法取得,返回 `-1`
**注意:**
- 取出字母的顺序没有要求
- 取出的所有字母恰好可以拼成 `helloleetcode`
**示例 1**
>输入:`words = ["hold","engineer","cost","level"]`