2019年3月1日 804. Unique Morse Code Words

依旧不是难题,练手练手,这道题本来准备一次AC的,结果出现了两个笔误+一次读题错误,失败,还需要努力。

class Solution(object):
    def uniqueMorseRepresentations(self, words):
        """
        :type words: List[str]
        :rtype: int
        """
        latter = [".-","-...","-.-.","-..",".","..-.",
                  "--.","....","..",".---","-.-",".-..",
                  "--","-.","---",".--.","--.-",".-.",
                  "...","-","..-","...-",".--","-..-",
                  "-.--","--.."]
        
        result = set()        
        for w in words:
            s = ''
            for i in w:
                s += latter[ord(i) - ord('a')]
            
            result.add(s,)

                    
        return len(result)
原文地址:https://www.cnblogs.com/seenthewind/p/10454661.html