package leetcode
type MagicDictionary struct {
rdict map[int]string
}
func Constructor676() MagicDictionary {
return MagicDictionary{rdict: make(map[int]string)}
}
func (this *MagicDictionary) BuildDict(dict []string) {
for k, v := range dict {
this.rdict[k] = v
}
}
func (this *MagicDictionary) Search(word string) bool {
for _, v := range this.rdict {
n := 0
if len(word) == len(v) {
for i := 0; i < len(v); i++ {
if word[i] != v[i] {
n += 1
}
}
if n == 1 {
return true
}
}
}
return false
}