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

View all comments

Show parent comment

2

u/tpb1908 Apr 03 '17

I believe mom is the same. I'm not sure if using Collections adds any noticeable overhead.

1

u/mr-rusof Apr 03 '17 edited Apr 03 '17