Prefix and Suffix Search
Design a special dictionary that searches words by a prefix and a suffix. Implement WordFilter with constructor that takes words array, and f(prefix, suffix) that returns the index of the word with given prefix and suffix. If multiple words match, return the largest index.
Prefix and Suffix Search

Design a special dictionary that searches words by a prefix and a suffix. Implement WordFilter with constructor that takes words array, and f(prefix, suffix) that returns the index of the word with given prefix and suffix. If multiple words match, return the largest index.

Example 1:
Input: {"words":["apple"],"queries":[["a","e"]]}
Output: [0]
Input
arr ={"words":["apple"],"queries":[["a","e"]]}

Words: [apple]

Words Dictionary

[0]

"apple"

Using prefix#suffix as key in hash map for O(1) lookup

Variables
No variables to display
DepthFunction Call
Stack empty
0/1