You are viewing a single comment's thread. Return to all comments →
.net solution
public static List matchingStrings(List stringList, List queries) {
List<int> match= new List<int>(); Dictionary<string,int> dict= new Dictionary<string,int>(); for(int i=0;i<stringList.Count;i++){ if(!dict.ContainsKey(stringList[i])){ dict.Add(stringList[i],1); }else{ dict[stringList[i]]++; } } for(int i=0;i<queries.Count;i++){ if(!dict.ContainsKey(queries[i])){ match.Add(0); }else{ match.Add(dict[queries[i]]); } } return match; }
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 →
.net solution
public static List matchingStrings(List stringList, List queries) {