[leetcode]211. Add and Search Word - Data structure design添加查找单词 - 数据结构设计

Posted 程序媛詹妮弗

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[leetcode]211. Add and Search Word - Data structure design添加查找单词 - 数据结构设计相关的知识,希望对你有一定的参考价值。

Design a data structure that supports the following two operations:

void addWord(word)
bool search(word)

search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.

Example:

addWord("bad")
addWord("dad")
addWord("mad")
search("pad") -> false
search("bad") -> true
search(".ad") -> true
search("b..") -> true

Note:
You may assume that all words are consist of lowercase letters a-z.

 

题意:

设计一个数据结构,能够插入单词,能够查找字符串,并支持正则表达式中的“.”单字符通配。

 

思路:

 

代码:

 


以上是关于[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

Leetcode 211: Add and Search Word - Data structure design

[LeetCode] 211. Add and Search Word - Data structure design Java

[leetcode trie]211. Add and Search Word - Data structure design

LeetCode 211. Add and Search Word - Data structure design(字典树)