- You have
setup()
function that accepts an array of words. - Calling
isInDict(word)
function by passing a single string word. Returns true if it includes in the dictionary which we have initialized fromsetup()
function. - The word we pass it to
isInDict()
function, may have wild cards which each wild card represent a single letter.
Dictionary initializatoin:
setup(['cat', 'car', 'bat', 'bald'])
Dictionary Loopup:
isInDict('cat') // true
isInDict('care') // false
isInDict('*at') // true, matches cat
isInDict('*a*') // true, matches, cat, car, bat
Result:
- The time complexity of your solution must be O(1).
- case-sensitivity is up to the coder.
Tips:
- You may use classes to persist the state of given dictionary.
- You may use key/value pairs for better performance.
- Remember you have
setup()
function to store the dictionary.