Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

reduce string

$
0
0

wats the problem with this code for reduce string problem given in hard practice section please tell?

include<stdio.h>

include<string.h>

int main() { int count[256]={0},i,j=0,n,k=0; char s[250],sb[20]; scanf("%s",&s); for(i=0;s[i]!='\0';i++) { count[s[i]]++;

}


scanf("%d",&n);

while(n--)
{
     scanf("%s",&sb);
for(i=0;sb[i]!='\0';i++)
    {
        for(j=0;s[j]!='\0';j++)
        {
            if(s[j]==sb[i])
            {
            count[s[j]]--;
            s[j]=-2;
            break;
            }
        }

      }


}

for(i=0;i<255;i++)
{
       if(count[i]!=0 && count[i]>0)
    {
      k+=count[i];

    }

}
printf("%d",k);

return 0; }


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>