You are viewing a single comment's thread. Return to all comments →
c#
public static int minimumDistances(List a)
{ List<int> distance = new List<int>(); for (int i = 0; i < a.Count(); i++) { for (int j = 0; j < a.Count(); j++) { if (i != j && a[i] == a[j]) { distance.Add(Math.Abs(j-i)); } } } if (!distance.Any()) { return -1; } else return distance.Min(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Distances
You are viewing a single comment's thread. Return to all comments →
c#
public static int minimumDistances(List a)