# Leetcode 804. Unique Morse Code Words

## 2. Solution

• Version 1
```class Solution:
def uniqueMorseRepresentations(self, words: List[str]) -> int:
az = [chr(x) for x in range(ord('a'), ord('z') + 1)]
morse = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
mapping = {}
for i in range(len(morse)):
mapping[az[i]] = morse[i]

result = set()
for word in words:
temp = ''
for ch in word:
temp = temp + mapping[ch]

return len(result)```

## Reference

1. https://leetcode.com/problems/unique-morse-code-words/

0 条评论

• ### LeetCode 804 Unique Morse Code Words

首先为每个单词的每个字符进行转码, 将转码后的数据放到 Set 集合中, 最后返回 Set 的长度。

• ### LeetCode 804. Unique Morse Code Words

International Morse Code defines a standard encoding where each letter is mapped...

• ### Leetcode-Easy 804. Unique Morse Code Words

804. Unique Morse Code Words 描述： 将26个因为字母映射为莫尔斯式电码 ? 思路： 一一匹配 代码 clas...

• ### LeetCode - 唯一摩尔斯密码词

LeetCode第804题，难度简单。莫尔斯码，记是记不住的，但是理解还是能够理解的。

• ### 2.leetcode唯一的摩斯密码

1.题目 International Morse Code defines a standard encoding where each letter is m...

• ### LeetCode 804. 唯一摩尔斯密码词（哈希+set）

国际摩尔斯密码定义一种标准编码方式，将每个字母对应于一个由一系列点和短线组成的字符串， 比如: “a” 对应 “.-”, “b” 对应 “-…”, “c” 对应...

• ### 力扣(LeetCode)刷题，简单题(第18期)

力扣(LeetCode)定期刷题，每期10道题，业务繁重的同志可以看看我分享的思路，不是最高效解决方案，只求互相提升。

• ### Leetcode 139 Word Break

Given a string s and a dictionary of words dict, determine if s can be segmente...