LinkedIn Interview question for Senior Software Engineer
Anonymous User
3632

Given a list of words {"java", "c++", "c#","git","java"}.
The function takes 2 words that always belong to the list. Find the minimum distance between the words in terms of postition.

Eg input->java,git
java found at indices 0,4
git at 3
so minimum distance is (4-3=1) and NOT (3-0=0)

I could not come up with optimal solution. Hence could not clear.

Comments (20)