/*
Given N strings, q queries
In each query who are given a string
print the frequency of that string
1<=N<=10^5
1<=|S|<=100
1<=q<=10^6
*/

#include <iostream>
#include<map>
#include<unordered_map>
using namespace std;
int main() {
    unordered_map<string,int> m;   //string--> to store input strings and int--> to store frequenices of string 
    int n; cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;   //here string will store in the map with initial frequeny 1 if there is any duplicate the value will get increment by 1
    }
    int q;
    cin>>q;
    while(q--){
        string s;
        cin>>s;
        cout<<m[s]<<"\n";
    }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: