SnackDown Contest

You and your roommate are teammates in SNACKDOWN competition. There are N questions in SNACKDOWN round numbered from 1 to N.  You can do some particular P questions while your roommate can do some particular Q questions. 

Now the question is will your team be able to solve all the N questions if you work together? 

Example:

Input:  n = 4, p = 3, a = [1,2,3], q=2, b= [2,4]  
Output: YES

Approach

C++

#include <bits/stdc++.h>
using namespace std;

bool snakdown(int nint pint a[], int qint b[])
{
    set<intst;
    for (int i = 0i < pi++)
        st.insert(a[i]);

    for (int i = 0i < qi++)
        st.insert(b[i]);
    if (st.size() == n)
        return true;
    else
        return false;
}
int main()
{
    int n = 4;

    int p = 3;
    int a[p] = {123};

    int q = 2;
    int b[q] = {24};

    if (snakdown(npaqb))
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}


No comments:

Post a Comment