You are viewing a single comment's thread. Return to all comments →
C# Solution
List<int> countArr = new List<int>(); //distinct check not required //List<string> distQuery = queries.Distinct().ToList(); var frequency = strings.GroupBy(x=>x).ToDictionary(x => x.Key, x => x.Count()); foreach(var q in queries) { if(frequency.ContainsKey(q)) { Console.WriteLine("{0} element has count of {1} ",q, frequency[q]); countArr.Add(frequency[q]); } else { countArr.Add(0); } } return countArr;
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →
C# Solution