I was practicing some questions from hacker rank and got stuck in this question called sparse-arrays. (https://www.hackerrank.com/challenges/sparse-arrays/problem) I am a beginner and i am not able to find out the error in my code. Please help. Thank you
I think I am not comparing the strings correctly. I tried using compare function but still it did not work.
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    cin>>n;
    string strings[n];
    for(int i=0; i<n; i++){
        cin>>strings[i];
    }
    int m;
    cin>>m;
    string queries[m];
    for(int i=0; i<m; i++){
        cin>>queries[i];
    }
     //comparing
        for(int i=0; i<m; i++)
    {
        int count=0;
        for(int j=0; j<n; j++)
        {
            if(queries[i]==strings[j])
                    count++;
        }
        cout<<count<<endl;
    }
}
The output should be the number of times the strings in (query) that have appeared in the (strings) but my program is getting terminated please help.
 
    