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)
标签:练手,...,Code,..,Morse,2019,result,words,ord 来源: https://www.cnblogs.com/seenthewind/p/10454661.html