can someone help me why only 2 test cases passed in my code, and which test case I might be missing?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void stringsearcher(int, int, int, int, int);
void oddeven(int, char *);
void oddeven(int len, char str[])
{
int ozeros, ezeros, eonce, oonce;
ezeros = 0, ozeros = 0;
eonce = 0, oonce = 0;
for (int cntr2 = 0; cntr2 < len; cntr2++)
{
if (cntr2 % 2 != 0)
{
if (str[cntr2] == '0')
{
ezeros = ezeros + 1;
}
else
{
eonce = eonce + 1;
}
}
else
{
if (str[cntr2] == '0')
{
ozeros = ozeros + 1;
}
else
{
oonce = oonce + 1;
}
}
}
stringsearcher(len, oonce, ozeros, eonce, ezeros);
}
void stringsearcher(int len, int oonce, int ozeros, int eonce, int ezeros)
{
int cntr;
int count = 0, count1 = 0;
char *strmake = (char *)malloc((len + 1) * sizeof(char));
for (cntr = 0; cntr < len; cntr++)
{
if (cntr % 2 == 0)
{
if (ozeros != 0)
{
strmake[cntr] = '0';
ozeros--;
}
else
{
strmake[cntr] = '1';
oonce--;
}
}
else
{
if (eonce != 0)
{
strmake[cntr] = '1';
eonce--;
}
else
{
strmake[cntr] = '0';
ezeros--;
}
}
}
count1 = substring_count(strmake);
printf("\n%s\n", strmake);
printf("%d\n", count1);
}
int substring_count(char *string)
{
int i, j, l1, l2;
int count = 0;
int found = 0;
char substring[] = "01";
l1 = strlen(string);
l2 = strlen(substring);
for (i = 0; i < l1 - l2 + 1; i++)
{
found = 1;
for (j = 0; j < l2; j++)
{
if (string[i + j] != substring[j])
{
found = 0;
break;
}
}
if (found)
{
count++;
i = i + l2 - 1;
}
}
return count;
}
int main()
{
int tst, len;
scanf("%d", &tst);
for (int cntr = 0; cntr < tst; cntr++)
{
scanf("%d", &len);
char *str = (char *)malloc((len + 1) * sizeof(char));
scanf("%s", str);
oddeven(len, str);
}
return 0;
}