mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
26 lines
1.2 KiB
HTML
26 lines
1.2 KiB
HTML
<p>On old cell phones, users typed on a numeric keypad and the phone would provide a list of words that matched these numbers. Each digit mapped to a set of 0 - 4 letters. Implement an algo­rithm to return a list of matching words, given a sequence of digits. You are provided a list of valid words. The mapping is shown in the diagram below:</p>
|
|
|
|
|
|
|
|
<p><img src="https://assets.leetcode-cn.com/aliyun-lc-upload/original_images/17_telephone_keypad.png" style="width: 200px;" /></p>
|
|
|
|
|
|
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input:</strong> num = "8733", words = ["tree", "used"]
|
|
|
|
<strong>Output:</strong> ["tree", "used"]
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input:</strong> num = "2", words = ["a", "b", "c", "d"]
|
|
|
|
<strong>Output:</strong> ["a", "b", "c"]</pre>
|
|
|
|
|
|
|
|
<p>Note:</p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>num.length <= 1000</code></li>
|
|
|
|
<li><code>words.length <= 500</code></li>
|
|
|
|
<li><code>words[i].length == num.length</code></li>
|
|
|
|
<li><code>There are no number 0 and 1 in num</code>.</li>
|
|
|
|
</ul>
|
|
|