• + 0 comments

    my approach with using c#

    public static int minimumDistances(List a) { var unique = a.GroupBy(p => p).Where(o => o.Count() > 1).Select(o => o.Key).ToList(); List differences = new List(); foreach(var i in unique) { differences.Add(a.LastIndexOf(i) - a.IndexOf(i)); } return differences.Count() > 0 ? differences.Min() : -1; }