You are viewing a single comment's thread. Return to all comments →
I notice alot of these solutions process 2x. an easy way is to just use Counter and collect values that have keys in the counter.
ex: (Psuedo)
result = [] c = Counter(strings)
for q in queries: c[q] ? result.append(c[q]) : result.append(0)
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 →
I notice alot of these solutions process 2x. an easy way is to just use Counter and collect values that have keys in the counter.
ex: (Psuedo)
result = [] c = Counter(strings)
for q in queries: c[q] ? result.append(c[q]) : result.append(0)