本文共 596 字,大约阅读时间需要 1 分钟。
set
class Solution(object): def uniqueMorseRepresentations(self, words): """ :type words: List[str] :rtype: int """ tables = [".-","-...","-.-.","-..",".","..-.","--.","....","..", ".---","-.-",".-..","--","-.","---",".--.","--.-",".-.", "...","-","..-","...-",".--","-..-","-.--","--.."] sets = set([]) for word in words: ret = '' for token in word: ret+=tables[ord(token)-ord('a')] sets.add(ret) return len(sets)
to be continue
转载地址:http://bbqmi.baihongyu.com/