UVA Solution 11849 CD

Solve in C++:


#include<bits/stdc++.h>
using namespace std;
main()
{
    long n,m;
    while(cin>>n>>m)
    {
        long i,a,cnt=0;
        map<long,long>mp;
        if(n==0&&m==0)
            break;
        for(i=1;i<=n;i++)
        {
            cin>>a;
            mp[a]=1;
        }
        for(i=1;i<=m;i++)
        {
            cin>>a;
            if(mp[a]==1)
                cnt++;
        }
        cout<<cnt<<endl;
    }
}

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.