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)/婴儿名字 [baby-names-lcci].html
2022-03-29 12:43:11 +08:00

20 lines
1.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

<p>每年政府都会公布一万个最常见的婴儿名字和它们出现的频率也就是同名婴儿的数量。有些名字有多种拼法例如John 和 Jon 本质上是相同的名字,但被当成了两个名字公布出来。给定两个列表,一个是名字及对应的频率,另一个是本质相同的名字对。设计一个算法打印出每个真实名字的实际频率。注意,如果 John 和 Jon 是相同的,并且 Jon 和 Johnny 相同,则 John 与 Johnny 也相同,即它们有传递和对称性。</p>
<p>在结果列表中,选择<strong> 字典序最小 </strong>的名字作为真实名字。</p>
<p> </p>
<p><strong>示例:</strong></p>
<pre>
<strong>输入:</strong>names = ["John(15)","Jon(12)","Chris(13)","Kris(4)","Christopher(19)"], synonyms = ["(Jon,John)","(John,Johnny)","(Chris,Kris)","(Chris,Christopher)"]
<strong>输出:</strong>["John(27)","Chris(36)"]</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>names.length <= 100000</code></li>
</ul>