sparse arrays hackerrank solution in python
from collections import Counter # module to count the values
#write your code here
store = Counter(strings)
ans = []
for q in queries:
ans.append(store[q])
return ans
sparse arrays hackerrank solution in python
from collections import Counter # module to count the values
#write your code here
store = Counter(strings)
ans = []
for q in queries:
ans.append(store[q])
return ans
sparse arrays hackerrank solution in python
store = dict()
ans = []
for w in strings:
if w in store:
store[w] +=1 #adding value to the key word(current word in string)
else:
store[w]=1 #assigning 1 to the new word in store
for q in queries:
if q in store:
ans.append(store[q])
else:
ans.append(0)
return ans
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us