1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最多牌组数 [Up5XYM].md
2022-03-29 12:43:11 +08:00

25 lines
736 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

麻将的游戏规则中,共有两种方式凑成「一组牌」:
- 顺子:三张牌面数字连续的麻将,例如 [4,5,6]
- 刻子:三张牌面数字相同的麻将,例如 [10,10,10]
给定若干数字作为麻将牌的数值(记作一维数组 `tiles`),请返回所给 `tiles` 最多可组成的牌组数。
注意:凑成牌组时,每张牌仅能使用一次。
**示例 1**
>输入:`tiles = [2,2,2,3,4]`
>
>输出:`1`
>
>解释:最多可以组合出 [2,2,2] 或者 [2,3,4] 其中一组牌。
**示例 2**
>输入:`tiles = [2,2,2,3,4,1,3]`
>
>输出:`2`
>
>解释:最多可以组合出 [1,2,3] 与 [2,3,4] 两组牌。
**提示:**
- `1 <= tiles.length <= 10^5`
- `1 <= tiles[i] <= 10^9`