745. prefix and suffix search

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:

  1. wordsThe length [1, 15000]between.
  2. For each test case, there will be at most words.lengthtimes of the WordFilter.fcalls.
  3. words[i]The length [1, 10]between.
  4. prefix, suffixIn length [0, 10]before.
  5. words[i]And prefix, suffixit contains only lowercase letters.

Guess you like

Origin blog.csdn.net/umbrellasoft/article/details/90376561