mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
update
This commit is contained in:
50
leetcode/problem/unique-morse-code-words.html
Normal file
50
leetcode/problem/unique-morse-code-words.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<p>International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>'a'</code> maps to <code>".-"</code>,</li>
|
||||
<li><code>'b'</code> maps to <code>"-..."</code>,</li>
|
||||
<li><code>'c'</code> maps to <code>"-.-."</code>, and so on.</li>
|
||||
</ul>
|
||||
|
||||
<p>For convenience, the full table for the <code>26</code> letters of the English alphabet is given below:</p>
|
||||
|
||||
<pre>
|
||||
[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]</pre>
|
||||
|
||||
<p>Given an array of strings <code>words</code> where each word can be written as a concatenation of the Morse code of each letter.</p>
|
||||
|
||||
<ul>
|
||||
<li>For example, <code>"cab"</code> can be written as <code>"-.-..--..."</code>, which is the concatenation of <code>"-.-."</code>, <code>".-"</code>, and <code>"-..."</code>. We will call such a concatenation the <strong>transformation</strong> of a word.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the number of different <strong>transformations</strong> among all words we have</em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> words = ["gin","zen","gig","msg"]
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> The transformation of each word is:
|
||||
"gin" -> "--...-."
|
||||
"zen" -> "--...-."
|
||||
"gig" -> "--...--."
|
||||
"msg" -> "--...--."
|
||||
There are 2 different transformations: "--...-." and "--...--.".
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> words = ["a"]
|
||||
<strong>Output:</strong> 1
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= words.length <= 100</code></li>
|
||||
<li><code>1 <= words[i].length <= 12</code></li>
|
||||
<li><code>words[i]</code> consists of lowercase English letters.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user