Given more words
, words[i]
the weight is i
.
Design a class WordFilter
to achieve function WordFilter.f(String prefix, String suffix)
. This function will return with the prefix prefix
and suffix suffix
of the word's greatest weight. If there is no such word, it returns -1.
example:
输入:
WordFilter(["apple"])
WordFilter.f("a", "e") // 返回 0
WordFilter.f("b", "") // 返回 -1
note:
words
The length[1, 15000]
between.- For each test case, there will be at most
words.length
times of theWordFilter.f
calls. words[i]
The length[1, 10]
between.prefix, suffix
In length[0, 10]
before.words[i]
Andprefix, suffix
it contains only lowercase letters.