The question was: given a dictionary ( array of English words) and a prefix as an input, return true if dictionary has the prefix?
For my brute forcesolution I looped over the dictionary and used startsWith method, and then tried to improve my solution by sorting the dictionary first. However the interviewee told me i can find a better solution which uses log(k) time complexity where k is the length of the longest word. i couldn't come up with a solution with O(log(k)). Can anyone help me? (I was coding in javascript)
Comments (8)


