Skip to content

Commit c7c10ab

Browse files
804_Unique_Morse_Code_Words
1 parent 942edcd commit c7c10ab

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

804_Unique_Morse_Code_Words.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
table = {'a':".-",'b':"-...",'c':"-.-.",'d':"-..",'e':".",'f':"..-.",'g':"--.",'h':"....",'i':"..",'j':".---",'k':"-.-",'l':".-..",'m':"--",'n':"-.",'o':"---",'p':".--.",'q':"--.-",'r':".-.",'s':"...",'t':"-",'u':"..-",'v':"...-",'w':".--",'x':"-..-",'y':"-.--",'z':"--.."}
3+
def uniqueMorseRepresentations(self, words):
4+
"""
5+
:type words: List[str]
6+
:rtype: int
7+
"""
8+
result = set()
9+
for each_word in words:
10+
temp = ''
11+
for each_c in each_word:
12+
temp += Solution.table[each_c]
13+
result.add(temp)
14+
return (len(result))
15+

0 commit comments

Comments
 (0)