My issue
there is some mistake in my code where cases are not working can u help me out fixing this question
My code
#include <iostream>
using namespace std;
bool check(int arr[], int n)
{
for (int i = 0; i < 2 * n; i++)
{
int count = 0;
for (int j = 0; j < 2 * n; j++)
{
if (i != j && arr[i] == arr[j])
{
count++;
}
}
if (count >= 3)
{
return false;
}
}
return true;
}
int main()
{
// your code goes here
int t;
cin >> t;
int n;
for (int i = 0; i < t; i++)
{
cin >> n;
int *a = new int[n];
for (int j = 0; j < n; j++)
{
cin >> a[j];
}
if (check(a, n))
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
return 0;
}
Problem Link: Candies Practice Coding Problem - CodeChef