r/csinterviewproblems • • Apr 02 '17

Shortest String Made of Allowed Letters

You are given a string and a set of letters. Your task is to return any shortest substring that consists of all and only the letters in the set.

Consider string aabxbcbaaccb and the set of letters {a,b,c}. The only possible answer is cba.

When there is no shortest substring, return the empty string.

Solution here: http://ruslanledesma.com/2017/04/01/shortest-substring-made-of-allowed-letters.html

2 Upvotes

13 comments sorted by