This is my code for the question, test cases are all passed, when i submit i am getting wrong answer. The code mentioned in the editorial is also same. but i don’t understand where my code is failing.
can anyone provide a test case where my code fails or let me know if there is any logical error in my code.
here is the code
bool solve()
{
int n, m, q;
cin >> n >> m >> q;
int arr[n+1] = {0};
char ch;
int i, count = 0;
for (int j = 1; j <= q; j++)
{
cin >> ch;
cin >> i;
if (ch == '+')
{
if (arr[i] == 0)
{
count++;
arr[i] = 1;
}
else
return false;
}
if (ch == '-')
{
if (arr[i] == 1)
count--;
else
return false;
}
if (count > m)
return false;
}
return true;
}