## bharajwad

int isSymmetric( struct Node *root1, struct Node *root2 )

{

if( root1 == NULL && root2 != NULL || root1 != NULL && root2 == NULL )

return 0;

if( root1 == NULL && root2 == NULL )

return 1;

if( root1->val != root2->val )

return 0;

if( isSymmetric( root1->left, root2->right ) && isSymmetric( root1->right, root2->left ) )

return 1;

else

return 0;

}

int compress( char *str )

{

if( NULL == str )

return 0;

if( NULL == str[0] )

return 0;

int k=0, prev=0, Rcount=0;

for(i=1; str[i] != NULL; i++)

{

if( str[i] != str[prev] )

{

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

Rcount = 0;

prev = i;

}

else

Rcount++;

}

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

str[k] = NULL;

return 1;

}

int compress( char *str )

{

if( NULL == str )

return 0;

if( NULL == str[0] )

return 0;

int k=0, prev=0, Rcount=0;

for(i=1; str[i] != NULL; i++)

{

if( str[i] != str[prev] )

{

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

Rcount = 0;

prev = i;

}

else

Rcount++;

}

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

str[k] = NULL;

return 1;

}

int compress( char *str )

{

if( NULL == str )

return 0;

if( NULL == str[0] )

return 0;

int k=0, prev=0, Rcount=0;

for(i=1; str[i] != NULL; i++)

{

if( str[i] != str[prev] )

{

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

Rcount = 0;

prev = i;

}

else

Rcount++;

}

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

str[k] = NULL;

return 1;

}

{

if( NULL == str )

return 0;

if( NULL == str[0] )

return 0;

int k=0, prev=0, Rcount=0;

for(i=1; str[i] != NULL; i++)

{

if( str[i] != str[prev] )

{

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

Rcount = 0;

prev = i;

}

else

Rcount++;

}

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

str[k] = NULL;

return 1;

}

{

if( NULL == str )

return 0;

if( NULL == str[0] )

return 0;

int k=0, prev=0, Rcount=0;

for(i=1; str[i] != NULL; i++)

{

if( str[i] != str[prev] )

{

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

Rcount = 0;

prev = i;

}

else

Rcount++;

}

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

str[k] = NULL;

return 1;

}

{

if( NULL == str )

return 0;

if( NULL == str[0] )

return 0;

int k=0, prev=0, Rcount=0;

for(i=1; str[i] != NULL; i++)

{

if( str[i] != str[prev] )

{

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

Rcount = 0;

prev = i;

}

else

Rcount++;

}

str[k++] = str[prev];

if( Rcount >= 1 ) str[k++] = Rcount + 1;

str[k] = NULL;

return 1;

}

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

For this question, 10 minutes would be a reasonable time to answer.

- bharajwad on February 04, 2013 Edit | Flag View Reply