Longest word with given prefix and suffix

Problem Statement

You are given a list of words, a prefix, and a suffix. You have to find the longest word in the given word list that has a given prefix and suffix. i.e. if the given prefix and suffix are P and S respectively then you have to find the longest word of pattern P*S.

If multiple words satisfy the given condition then return the lexicographically small one. If no word satisfies the condition return an empty string.

For example:

wordlist = ["apple", "appe", "word", "alloye"]prefix =...
 •  0 comments  •  flag
Share on Twitter
Published on June 22, 2022 03:00
No comments have been added yet.