leetcode 211. Add and Search Word
来源:互联网 发布:云豹直播源码 编辑:程序博客网 时间:2024/05/24 20:07
class WordDictionary(object): """ https://discuss.leetcode.com/topic/29809/python-168ms-beat-100-solution """ def __init__(self): """ Initialize your data structure here. """ self.words = collections.defaultdict(list) def addWord(self, word): """ Adds a word into the data structure. :type word: str :rtype: void """ self.words[len(word)].append(word) def search(self, word): """ Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter. :type word: str :rtype: bool """ for a in self.words[len(word)]: for i,c in enumerate(word): if a[i] != c and c != '.': break else: return True return False# Your WordDictionary object will be instantiated and called as such:# obj = WordDictionary()# obj.addWord(word)# param_2 = obj.search(word)
阅读全文
0 0
- Leetcode 211. Add and Search Word
- [Leetcode] 211. Add and Search Word
- [leetcode]211. Add and Search Word
- leetcode 211. Add and Search Word
- leetcode 211. Add and Search Word
- leetcode 211. Add and Search Word
- [LeetCode] Add and Search Word
- leetcode--Add and Search Word
- 211. Add and Search Word
- 211. Add and Search Word
- 211. Add and Search Word
- [leetcode] 211.Add and Search Word - Data structure design
- LeetCode 211. Add and Search Word - Data structure design
- [Leetcode]211. Add and Search Word - Data structure design @python
- Leetcode 211. Add and Search Word - Data structure design
- 211. Add and Search Word - Data structure design LeetCode
- leetcode 211. Add and Search Word - Data structure design
- LeetCode 211. Add and Search Word - Data structure design
- 使用fetch下载文件
- 科技论文的框架
- 集合List:ArrayList,接口的常用方法
- git vim基本命令
- phpstorm xdebug chrome 安装调试
- leetcode 211. Add and Search Word
- <job_mode><Qt>多测试设备波形图
- idea 创建SSH项目的maven依赖
- Java并发编程:进程和线程之由来
- Spring boot框架请求数据库的url地址
- Image-Loader的使用
- react-native启动android service bug解决办法
- Java并发编程:如何创建线程?
- List存储对象的简单应用,List返回一个Object对象,要强转为子类对象。