Bar and Foo

Asked at Meta · Coding Questions · Difficulty: Medium

You are given a list of strings (words) and a string s. Your task is to find the longest word in the list that can be constructed by deleting some characters of the string s (without re-arranging the other characters). If multiple words have the same length, you should choose the one that is smallest in lexicographical order. The given string s will have a length of at most 1000, the words will also have a maximum length of 50, and the number of words will not exceed 1000.

Loading the problem…