Interview Question
SDE1sCountry: India
void checkBalance(string str)
{
char temp[MAXLEN];
int i, j;
for (i = j = 0; temp[i] = str[j]; j++)
{
if (str[j+1] == temp[i]) // accessing more than last element of str
i++;
}
if (i == 0)
printf("Balanced\n");
else
printf("Not Balanced\n");
}
the error is in line:
It should be:
- zr.roman November 18, 2015