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)
上一篇:2020年G2电站锅炉司炉模拟考试及G2电站锅炉司炉证考试


下一篇:ch(),unichr(),ord()