804. Unique Morse Code Words Easy
1/**
2 * [804] Unique Morse Code Words
3 *
4 * International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:
5 *
6 * 'a' maps to ".-",
7 * 'b' maps to "-...",
8 * 'c' maps to "-.-.", and so on.
9 *
10 * For convenience, the full table for the 26 letters of the English alphabet is given below:
11 *
12 * [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
13 * Given an array of strings words where each word can be written as a concatenation of the Morse code of each letter.
14 *
15 * For example, "cab" can be written as "-.-..--...", which is the concatenation of "-.-.", ".-", and "-...". We will call such a concatenation the transformation of a word.
16 *
17 * Return the number of different transformations among all words we have.
18 *
19 * Example 1:
20 *
21 * Input: words = ["gin","zen","gig","msg"]
22 * Output: 2
23 * Explanation: The transformation of each word is:
24 * "gin" -> "--...-."
25 * "zen" -> "--...-."
26 * "gig" -> "--...--."
27 * "msg" -> "--...--."
28 * There are 2 different transformations: "--...-." and "--...--.".
29 *
30 * Example 2:
31 *
32 * Input: words = ["a"]
33 * Output: 1
34 *
35 *
36 * Constraints:
37 *
38 * 1 <= words.length <= 100
39 * 1 <= words[i].length <= 12
40 * words[i] consists of lowercase English letters.
41 *
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/unique-morse-code-words/
46// discuss: https://leetcode.com/problems/unique-morse-code-words/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51 pub fn unique_morse_representations(words: Vec<String>) -> i32 {
52 0
53 }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60 use super::*;
61
62 #[test]
63 fn test_804() {
64 }
65}
66
Back
© 2025 bowen.ge All Rights Reserved.