You are viewing a single comment's thread. Return to all comments →
Python solution for O(n+m) time complexity
def matchingStrings(stringList, queries): d = {} c = [] for i in stringList: d[i] = 0 for a in stringList: if a in d.keys(): d[a] += 1 for b in queries: if b in d.keys(): c.append(d.get(b)) else: c.append(0) return c
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 →
Python solution for O(n+m) time complexity