• + 0 comments

    Here's my easy understandable solution in C++, just ask gpt to do formatting of code (if not presentable).

    include

    using namespace std; void matching_func(string str_list[], int str_size, string que_list[], int que_size) { // this function will match the queries and str indexes and // also directly print the results. int result; for(int q_index = 0; q_index < que_size; q_index++) { result = 0; // to make results 0 for each query start for(int str_index = 0; str_index < str_size; str_index++) {
    // this inner loop will match specific query index element to string index elements. if(que_list[q_index] == str_list[str_index]) { result++; // if matched, then only increase the value } } cout << result << endl; } } void input_arr(int size, string arr[]) { for (int index = 0; index < size; index++) { cin >> arr[index]; } } int main() { int size_string_list, size_query_list; cin >> size_string_list; string string_list[size_string_list]; input_arr(size_string_list, string_list); cin >> size_query_list; string query_list[size_query_list]; input_arr(size_query_list, query_list); matching_func(string_list, size_string_list, query_list, size_query_list); // here we have just taken the input of size and list return 0; }