Sparse Arrays

Sort by

recency

|

419 Discussions

|

  • + 0 comments
    def matchingStrings(strings, queries):
        # Write your code here
        count_arr=[]
        for i in queries:
            count=0
            for item in strings:
                if i == item:
                    count+=1
            count_arr.append(count)
        return count_arr``
    
  • + 0 comments
        public static List<int> matchingStrings(List<string> strings, List<string> queries)
        {
            return queries.GroupJoin(strings, q => q, s => s, (q, ss) => ss.Count()).ToList();
        }
    
  • + 0 comments

    The provided test runner code for golang is broken. It overwrites the strings package with an array of strings.

  • + 0 comments

    def matchingStrings(strings, queries): results = []

    for i in queries:
        sum = 0
        for j in strings:
            # print(i,j)
            if i == j:
                # print(i,j)
                sum+=1
        results.append(sum)
    return(results)
    
  • + 0 comments
    def matchingStrings(strings, queries):
        # Write your code here
        results=[0]*len(queries)
        for query_index in range(0,len(queries)):
            for string in strings:
                if queries[query_index] == string:
                    results[query_index]+=1
                    
        return results