Answers for "hackerrank sparse arrays solution javasript"

1

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
Posted by: Guest on July-18-2021
1

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
Posted by: Guest on July-18-2021

Code answers related to "hackerrank sparse arrays solution javasript"

Python Answers by Framework

Browse Popular Code Answers by Language