problem0211

package
v0.0.0-...-899dd15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 0 Imported by: 0

README

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.

For 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.

click to show hint.

You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first.

解题思路

见程序注释

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WordDictionary

type WordDictionary struct {
	// contains filtered or unexported fields
}

func Constructor

func Constructor() WordDictionary

* Initialize your data structure here.

func (*WordDictionary) AddWord

func (this *WordDictionary) AddWord(word string)

* Adds a word into the data structure.

func (*WordDictionary) Search

func (this *WordDictionary) Search(word string) bool

* Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL