Skip to content

Instantly share code, notes, and snippets.

@SahilKadam
Created October 23, 2016 18:45
Show Gist options
  • Save SahilKadam/e0e14a2e256b8e8233d0b1102d5168ed to your computer and use it in GitHub Desktop.
Save SahilKadam/e0e14a2e256b8e8233d0b1102d5168ed to your computer and use it in GitHub Desktop.
There are strings. Each string's length is no more than characters. There are also queries. For each query, you are given a string, and you need to find out how many times this string occurred previously. Input Format The first line contains , the number of strings. The next lines each contain a string. The nd line contains , the number of queri…
N = int(input().strip())
def wordCount(word):
global words
res = [item for item in words if item == word]
return len(res)
words = [input().strip() for i in range(N)]
N_Q = int(input().strip())
query = [print (wordCount(input().strip())) for i in range(N_Q)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment