Help me in solving MISSP problem

My issue

why my code cannot complete all test cases.

My code

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

int main() {
    // your code goes here
    int a, b, c, k, d, i, q;
    unordered_map<int, int> l;
    cin >> a;
    while (a--) {
        cin >> b;
        q = b;
        int arr[b];
        k = INT_MIN;
        d = INT_MAX;
        i = 0;
        while (b--) {
            cin >> arr[i];
            l[arr[i]]++;
            i++;
        }
        for (int j = 0; j < q; j++) {
            if (arr[j] > k) {
                k = arr[j];
            }
        }
        for (int j = 0; j < q; j++) {
            if (arr[j] < d) {
                d = arr[j];
            }
        }
        for (int p = d; p <= k; p++) {
            if (l[p] != 2) {
                cout << p <<" ";
            }
        }

        l.clear();
        cout<<endl;
    }
    return 0;
}

Problem Link: Chef and Dolls Practice Coding Problem - CodeChef

@anon50671123
dude the logic is quite simple just calculate the xor of the whole array , and the result will the answer.
refer my c++ code

#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int a[n];
        int ans=0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            ans^=a[i];
        }
    cout<<ans<<endl;
    }
    return 0;
}

thank you