In the one dimensional array S , There might be any number of elements that belong to the set
U:{A,B,C,D,E}
and repetition is allowed.
Example :
S = {E,B,D,C,A,D,A,E,E,D,B,B,A,C}
Question is:
What is the most efficient way in which I can determine the shortest range/path that contains all the elements belonging to set U ,In any given array S ? keep in mind the array can't be sorted.
In the above example the shortest path is that connecting the first 5 elements of the array S.
EDIT :
1) The Number Of Elements of set U isn't constant.
Thanks in advance.